简体   繁体   English

Qt Creator。 为什么在编译发行版本时出现关于glut的错误,但没有调试?

[英]Qt Creator. Why do I get an error about glut when compiling release version, but not debug?

I'm rather new to Qt and I'm having trouble building a stand alone executable for my application. 我对Qt相当陌生,无法为我的应用程序构建独立的可执行文件。 It has OpenGL widgets and I've used glut32 library. 它具有OpenGL小部件,并且我使用了glut32库。 The thing is that I've been buiding it fine in debug mode, but following the steps given here: 问题是,我一直在调试模式下很好地进行构建,但是请按照此处给出的步骤进行操作:

How to create executable file for a Qt Application? 如何为Qt应用程序创建可执行文件?

It gives an error when buiding it in release mode: 在发布模式下构建时会出现错误:

" Undifined reference to ___glutInitWithExit " “对___glutInitWithExit的未定义引用”

It's the very same code. 这是完全相同的代码。 I don't understand why it is having trouble under release. 我不明白为什么发布时会遇到麻烦。

I thank in advance any tips to help me buid a standalone executable. 在此先感谢任何帮助我构建独立可执行文件的技巧。

For static single executables you will first need a commercial license for QT. 对于静态单个可执行文件,您首先需要QT的商业许可证。 This being said you can change the mkspecs in $QTDIR\\mkspecs\\$COMPILERVERSION\\qmake.conf to use static linking. 据说您可以将$ QTDIR \\ mkspecs \\ $ COMPILERVERSION \\ qmake.conf中的mkspecs更改为使用静态链接。 For example win32-msvc2008 (2008 Visual Studio Compiler) set CFLAGS and CXXFLAGS from 例如win32-msvc2008(2008 Visual Studio编译器)将CFLAGS和CXXFLAGS设置为

QMAKE_CFLAGS_RELEASE    = -O2 -MD

to

QMAKE_CFLAGS_RELEASE    = -O2 -MT

(MD => MT, MDd => MTd). (MD => MT,MDd => MTd)。 Furthormore you will static libs of QT and GLUT. 此外,您将静态QT和GLUT库。 These typically end in .lib (not .dll). 这些文件通常以.lib(不是.dll)结尾。 You probably will need to compile QT from Source for getting static-compatible libraries. 您可能需要从Source编译QT以获得静态兼容的库。 When compiling QT remember to compile with opengl support. 编译QT时,请记住使用opengl支持进行编译。 There is a good documentation at http://qt-project.org/wiki/Build_Static_Qt_For_Windows_With_Gcc_German for gcc, and you can also find examples for MSVC. http://qt-project.org/wiki/Build_Static_Qt_For_Windows_With_Gcc_German上有一个很好的gcc文档,您也可以找到MSVC的示例。

After these prerequisites are met you still need to set in your Application-pro-file 满足这些先决条件后,您仍然需要在Application-pro-file中进行设置

CONFIG += static

and include your libraries with: 并在您的库中包含以下内容:

LIBS += -Lpath/to/glutlib -lglut

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Qt Creator 中调试与运行。 不同的数值 - Debug vs Run in Qt Creator. Different numerical values Qt Creator:启用Shadow Builds后,为什么会出现与丢失文件有关的错误? - Qt Creator: When I enable Shadow Builds, why do I get error related to missing files? 在 Qt Creator 中构建错误,但在调试中没有 - Build error in Qt Creator in release but not in debug 为什么用Qt Creator在C中编译代码时出现错误,但是可以使用make文件轻松地做到这一点? - Why do I have an error while compiling my code in C with Qt creator but can easily do this using make file? 为 Symbian 编译 Qt Creator 项目时出现错误:“未定义对 `__cxa_get_exception_ptr' 的引用” - Error: "undefined reference to `__cxa_get_exception_ptr'" when compiling Qt Creator project for Symbian 使用qmake / Qt Creator链接调试/发布库 - Linking with a debug/release lib with qmake/Qt Creator 在Qt Creator中进行编译时在Qt中出现Libvirt错误 - Libvirt in Qt error while compiling in Qt Creator Qt Creator。 更改插槽的代码生成模板 - Qt Creator. Change code generating template for slots 我似乎无法在qt Creator中打印几行数据。 程序将覆盖除最后一行以外的所有输出 - I can't seem to print several lines of data in qt creator. Program overwrites all output except for the last line Qt创建者。 从文件中读取并在beaggleboard上打印出来 - Qt creator. read from a file and print it out on beaggleboard
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM