I've been trying to get some simple GL code that implements GFLW3 to compile on QT Creator (on Ubuntu 13.04). However I keep getting the same output when it tries building:
我一直在尝试获得一些简单的GL代码,实现GFLW3编译在QT创建者上(在Ubuntu 13.04上)。然而,当它尝试构建时,我仍然得到相同的输出:
undefined reference to symbol 'XF86VidModeQueryExtension'
I then went to the .pro file and linked the lXxf86vm.so library file and added -lXxf86vm but it still gives the same output:
然后我转到.pro文件,并链接了lXxf86vm。因此,库文件和添加的-lXxf86vm,但它仍然提供相同的输出:
g++ -m64 -o GL-Test main.o windowtest.o frametest.o -L/usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 -L/user/lib/x86_64-linux-gnu/libXxf86vm.so
-L/user/lib/x86_64-linux-gnu/libXxf86vm.a -L/user/lib/x86_64-linux-gnu/libXxf86vm.so.1.0.0
-L/home/syk435/Testing\ Gl/GL-Test/../../../../usr/lib/x86_64-linux-gnu/ -lXxf86vm -lX11 -lGL -L/usr/local/lib -lglfw3
/usr/bin/ld: /usr/local/lib/libglfw3.a(x11_init.c.o): undefined reference to symbol 'XF86VidModeQueryExtension'
/usr/bin/ld: note: 'XF86VidModeQueryExtension' is defined in DSO /home/syk435/Testing Gl/GL-Test/../../../../usr/lib/x86_64-linux-gnu//libXxf86vm.so
so try adding it to the linker command line
/home/syk435/Testing Gl/GL-Test/../../../../usr/lib/x86_64-linux-gnu//libXxf86vm.so:
could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
as you can see, I've tried four different ways to link the correct lib but it's still giving me the same "undefined reference" and "symbols could not be read" errors. Any insight on the proper way to link?
正如您所看到的,我尝试了四种不同的方法来链接正确的lib,但它仍然给了我相同的“未定义引用”和“不能读取符号”的错误。有什么正确的联系方式吗?
Edit: Pro file: TEMPLATE = app
编辑:Pro file: TEMPLATE = app。
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
CONFIG += link_pkgconfig
PKGCONFIG += x11
CONFIG += link_pkgconfig
PKGCONFIG += gl
CONFIG += link_pkgconfig
PKGCONFIG += glfw3
LIBS += -lXxf86vm -L/usr/lib/x86_64-linux-gnu/libXxf86vm.so.1
LIBS += -lXxf86vm -L/user/lib/x86_64-linux-gnu/libXxf86vm.so
LIBS += -lXxf86vm -L/user/lib/x86_64-linux-gnu/libXxf86vm.a
LIBS += -lXxf86vm -L/user/lib/x86_64-linux-gnu/libXxf86vm.so.1.0.0
1 个解决方案
#1
2
The problem is here:
这里的问题是:
LIBS += -lXxf86vm -L/usr/lib/x86_64-linux-gnu/libXxf86vm.so.1
LIBS += -lXxf86vm -L/user/lib/x86_64-linux-gnu/libXxf86vm.so
LIBS += -lXxf86vm -L/user/lib/x86_64-linux-gnu/libXxf86vm.a
LIBS += -lXxf86vm -L/user/lib/x86_64-linux-gnu/libXxf86vm.so.1.0.0
You are using the -L
option with a file name rather than a path! You should change those four lines to:
您使用的是-L选项,使用的是文件名而不是路径!你应该把这四行改为:
LIBS += -lXxf86vm -L/user/lib/x86_64-linux-gnu/
Secondly, if the ordering matters, you would need to use LIBS
for glfw3, too, something like this:
其次,如果排序很重要,你也需要用LIBS来表示glfw3,类似这样的东西:
LIBS += -lglfw3 -lXxf86vm -L/user/lib/x86_64-linux-gnu/
Do not forget to assign the glfw3 path as well if needed. That is depending on your setup. You could probably try to swap the order of your current PKGCONFIG and LIBS statements, but it is not that much future proof if you move code around. Also, if you can share the path between the two libraries, I would not personally use PKGCONFIG, just LIBS.
如果需要,不要忘记分配glfw3路径。这取决于你的设置。您可能会尝试交换当前PKGCONFIG和LIBS语句的顺序,但是如果您在周围移动代码,它就不是那么多的未来证据了。另外,如果您可以共享两个库之间的路径,我不会使用PKGCONFIG,只是LIBS。
#1
2
The problem is here:
这里的问题是:
LIBS += -lXxf86vm -L/usr/lib/x86_64-linux-gnu/libXxf86vm.so.1
LIBS += -lXxf86vm -L/user/lib/x86_64-linux-gnu/libXxf86vm.so
LIBS += -lXxf86vm -L/user/lib/x86_64-linux-gnu/libXxf86vm.a
LIBS += -lXxf86vm -L/user/lib/x86_64-linux-gnu/libXxf86vm.so.1.0.0
You are using the -L
option with a file name rather than a path! You should change those four lines to:
您使用的是-L选项,使用的是文件名而不是路径!你应该把这四行改为:
LIBS += -lXxf86vm -L/user/lib/x86_64-linux-gnu/
Secondly, if the ordering matters, you would need to use LIBS
for glfw3, too, something like this:
其次,如果排序很重要,你也需要用LIBS来表示glfw3,类似这样的东西:
LIBS += -lglfw3 -lXxf86vm -L/user/lib/x86_64-linux-gnu/
Do not forget to assign the glfw3 path as well if needed. That is depending on your setup. You could probably try to swap the order of your current PKGCONFIG and LIBS statements, but it is not that much future proof if you move code around. Also, if you can share the path between the two libraries, I would not personally use PKGCONFIG, just LIBS.
如果需要,不要忘记分配glfw3路径。这取决于你的设置。您可能会尝试交换当前PKGCONFIG和LIBS语句的顺序,但是如果您在周围移动代码,它就不是那么多的未来证据了。另外,如果您可以共享两个库之间的路径,我不会使用PKGCONFIG,只是LIBS。