如果我尝试执行here, the OpenGLBook中的代码,我会收到以下错误消息:
undefined reference to glutMainLoop
undefined reference to glGetString
undefined reference to glClearColor
依旧......我安装了以下软件包:
libglew-dev
,liblglew1.8
,freeglut3-dev
和freeglut3
。
我使用Qt Creator v3.0.0在Ubuntu 13.10上运行。
我的.pro
文件如下所示:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
调试的构建步骤是qmake Project.pro -r -spec linux-g++ CONFIG += debug
如何修复项目?
答案 0 :(得分:3)
必须将我的pro
文件更改为
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
# this is the important part
unix|win32: LIBS += -lGLU
unix|win32: LIBS += -lGL
unix|win32: LIBS += -lglut
答案 1 :(得分:0)
欢迎使用c ++! 您正在使用一个库(我收集的freeglut),为此您需要两件事:
1)包含声明你需要的函数/类/方法的头文件(* .h文件)
2)您的程序需要链接到实际的共享库(Linux中的.so文件)
在.pro文件中,您需要指定要链接的库的路径。加上这个:
LIBS + = -lglut
这意味着将库过剩添加到要链接的库列表中。