質問

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:

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:

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?

Edit: 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
役に立ちましたか?

解決

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:

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 += -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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top