Qt 添加 libQGLViewer

如何解决Qt 添加 libQGLViewer

我正在尝试在 Qt 中使用 libQGLViewer 库。我正在遵循官方安装过程。但是我在 [Code] var VersionSelectionPage: TInputOptionWizardPage; procedure InitializeWizard(); begin VersionSelectionPage := CreateInputOptionPage(wpInfoBefore,'Version selection','',True,False); VersionSelectionPage.Add('1.0'); VersionSelectionPage.Add('2.0'); VersionSelectionPage.Add('3.0'); VersionSelectionPage.SelectedValueIndex := 0; end; function NextButtonClick(CurPageID: Integer): Boolean; var Dir: string; begin if CurPageID = VersionSelectionPage.ID then begin case VersionSelectionPage.SelectedValueIndex of 0: Dir := ExpandConstant('{pf}\My Program v1'); 1: Dir := ExpandConstant('{pf}\My Program v2'); 2: Dir := ExpandConstant('{pf}\My Program v3'); else RaiseException('Unexpected selection'); end; WizardForm.DirEdit.Text := Dir; end; Result := True; end; 文件中仍然有一些错误。

simpleViewer.h

我想解释一下我的安装过程,所以我可能犯了一些错误。

1- 我尝试了一个 Qt OpenGl 示例,效果很好。

2- 我安装并解压了文件。

3- 我构建了C:\Users\Halil\yedekleme\Belgeler\untitled\simpleViewer.h:1: error: QGLViewer/qglviewer.h: No such file or directory In file included from ..\untitled\simpleViewer.cpp:1:0: ..\untitled\simpleViewer.h:1:10: fatal error: QGLViewer/qglviewer.h: No such file or directory #include <QGLViewer/qglviewer.h> ^~~~~~~~~~~~~~~~~~~~~~~ 文件,然后将文件 QGLViewer.pro QGLViewer2.dll 复制到我的 System32 目录中。然后我跳过了编译。

4- 我创建了一个 QWidget 项目并将此代码添加到 .pro 文件中:

QGLViewer2d.dll

现在我看到它看到了文件,因为我得到的唯一错误是在上面。

而且我把我的所有代码都加在这里了,可能是我在代码库中犯了一些错误。 untitled.pro

INCLUDEPATH += C:/Users/Halil/yedekleme/Masaüstü/libQGLViewer-2.7.2
LIBS += -LC:/Users/Halil/yedekleme/Masaüstü/libQGLViewer-2.7.2/QGLViewer -lQGLViewer2

ma​​in.cpp


greaterThan(QT_MAJOR_VERSION,4): QT += widgets

CONFIG += c++11

SOURCES += \
    main.cpp \
    simpleViewer.cpp

HEADERS += \
    simpleViewer.h

FORMS += \
simpleViewer.ui

INCLUDEPATH += C:/Users/Halil/yedekleme/Masaüstü/libQGLViewer-2.7.2
LIBS += -LC:/Users/Halil/yedekleme/Masaüstü/libQGLViewer-2.7.2/QGLViewer -lQGLViewer2


# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

simpleViewer.h

#include <qapplication.h>

int main(int argc,char **argv) {
  // Read command lines arguments.
  QApplication application(argc,argv);

  // Instantiate the viewer.
  Viewer viewer;

  viewer.setWindowTitle("simpleViewer");

  // Make the viewer window visible on screen.
  viewer.show();

  // Run main loop.
  return application.exec();
}

simpleViewer.cpp


class Viewer : public QGLViewer {
protected:
  virtual void draw();
  virtual void init();
  virtual QString helpString() const;
};

感谢您的到来。

解决方法

  1. 切勿触摸 Windows 系统目录。如果您必须切换到管理模式,请停止并不要这样做。去掉那些 dll,90 年代正是地狱,因为每个人都认为这是这样做的方式 - 事实上,除了共享的、已安装的 COM 服务器和运行时库(例如 C/ C++ 运行时)。

    MS 在传达这一点时遇到了一些问题,很清楚:( 他们的文档在未说明的事情背后留下了很多推理,并且以某种方式希望开发人员能够确定最佳实践。

    在这一点上,The Old New Thing blog 是适用于 Windows 的事实上的规范“执行此操作和原因”文档。它肯定比大多数文档更易于阅读,因为条目几乎都设置为故事,我们人类对故事很感兴趣:) 不幸的是,没有目录(据我所知),但搜索有效。

  2. 构建库时,您可以将其构建为项目的一部分(首选),也可以构建独立库,然后将其安装在某处。编写合理的构建脚本(无论是 qmake 还是 cmake)支持选择安装目录,这应该在您的主配置文件路径中的某个位置(在 %USERPROFILE% 下)。作为项目的一部分进行构建通常要容易得多。

  3. 因此,将库添加为主项目中的子目录子项目。它将与您的代码一起构建,而 qmake 将处理细节。谷歌关于如何告诉 qmake 使用来自其他目标的库目标 - 这有点令人费解,因为 qmake 并没有做支持它所需的一切。理想情况下,正在构建的库甚至应该对 prl 文件进行评级,然后在使用它的项目中使用该文件。 PRL 文件是一个实现细节,但在 qmake 中没有简单的方法可以把它扫到地毯下。这就是为什么我建议使用 cmake 代替,如果没有,则将库的构建脚本移植到 cmake。然后,使用该库变得非常简单 - 您只需将其名称添加到使用者项目中的 target_link_libraries 中,所有其他魔法,例如包含路径、所需的编译器定义(任意)等,都会根据需要进行处理.

TL;DR:不要使用 qmake 开发任何新东西。如果库没有提供它们,则将库构建脚本移植到 cmake。在构建 cmake 项目时使用 ninja - 快如闪电。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-