【问题标题】:Generated .pro file from visual studio Qt addin adds unnecessary openGL libraries?从 Visual Studio Qt 插件生成的 .pro 文件添加了不必要的 openGL 库?
【发布时间】:2012-09-26 19:57:58
【问题描述】:

我在 Visual Studio 中使用 Qt 和 openGL 小部件创建了一个基本应用程序。我从插件中导出了一个 .pro 文件,以便在 Linux 中编译。

我收到消息:

/usr/bin/ld: cannot find -lopengl32
/usr/bin/ld: cannot find -lglu32

...运行 make 时。

如果我删除,问题就会消失,程序可以正常编译:

LIBS += -lopengl32 \
    -lglu32

...来自生成的 .pro 文件。

我了解“导出 .pro”功能并非完美无缺,但这是解决此问题的正确方法吗?

【问题讨论】:

    标签: visual-studio-2010 qt opengl makefile


    【解决方案1】:

    我不太记得 Linux 上 OpenGL 库的确切名称,但它不是 opengl32。而是libopengl。所以这很正常。

    这将使您仅在 Windows 上与 opengl32.lib 链接:

    win32 : LIBS += -lopengl32 -lglu32
    

    如果需要,这将使您与 Linux 上的 libopengl 链接:

    unix : LIBS += -lopengl -lglu
    

    对于macx 平台范围,我想还有额外的工作要与 OpenGL 框架链接。

    【讨论】:

    • 谢谢,在 Qt .pro 文件中我已经指定它应该加载 openGL 模块,并且我假设它会为我加载特定于平台的库。似乎 Visual Studio 项目文件必须包含这些 Windows 库,因此即使 Qt 模块会自动包含正确的库,它也会尝试将它们放入 make 文件中。
    • 好的,所以你只需要QT += core gui openglwin32 : LIBS += -lopengl32 -lglu32,对吗?
    • win32 库似乎可以完全省略,因为 qmake 会将正确的库添加到任何系统上生成的 Makefile 中。
    猜你喜欢
    • 1970-01-01
    • 2014-07-03
    • 2021-12-18
    • 1970-01-01
    • 2014-02-19
    • 2013-06-28
    • 2019-07-29
    • 1970-01-01
    • 2012-05-29
    相关资源
    最近更新 更多