我无法使用 cmake 链接静态库
我尝试将 X11、giblib 作为静态库与 cmake 链接。
所以我将此代码附加到 CMakeLists.txt
set(BUILD_SHARED_LIBS FALSE)
set(CMAKE_EXE_LINKER_FLAGS '-static')
target_link_libraries(Printmade2 Imlib2)
target_link_libraries(Printmade2 /usr/lib/i386-linux-gnu/libX11.a)
target_link_libraries(Printmade2 /usr/lib/libgiblib.a)
执行“make”后,出现此消息。
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(OpenDis.o): In function `OutOfMemory':
(.text+0x459): undefined reference to `xcb_disconnect'
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(OpenDis.o): In function `XOpenDisplay':
(.text+0x8f5): undefined reference to `xcb_get_setup'
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(OpenDis.o): In function `XOpenDisplay':
(.text+0xedb): undefined reference to `xcb_get_maximum_request_length'
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x176): undefined reference to `xcb_parse_display'
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x1d7): undefined reference to `xcb_connect_to_display_with_auth_info'
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x1f5): undefined reference to `xcb_get_file_descriptor'
...
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(ClDisplay.o): In function `XCloseDisplay':
(.text+0xbd): undefined reference to `xcb_disconnect'
collect2: ld returned 1 exit status
我猜想遗漏了某些内容,所以我应该链接更多内容
,但我在文件系统中找不到 .o 文件。
(例如,OpenDis.o、xcb_disp.o、ClDisplay.o)
我应该怎么做才能解决这个问题?
I try to link X11, giblib as static library with cmake.
So I append this code in CMakeLists.txt
set(BUILD_SHARED_LIBS FALSE)
set(CMAKE_EXE_LINKER_FLAGS '-static')
target_link_libraries(Printmade2 Imlib2)
target_link_libraries(Printmade2 /usr/lib/i386-linux-gnu/libX11.a)
target_link_libraries(Printmade2 /usr/lib/libgiblib.a)
After execute 'make', this message appears.
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(OpenDis.o): In function `OutOfMemory':
(.text+0x459): undefined reference to `xcb_disconnect'
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(OpenDis.o): In function `XOpenDisplay':
(.text+0x8f5): undefined reference to `xcb_get_setup'
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(OpenDis.o): In function `XOpenDisplay':
(.text+0xedb): undefined reference to `xcb_get_maximum_request_length'
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x176): undefined reference to `xcb_parse_display'
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x1d7): undefined reference to `xcb_connect_to_display_with_auth_info'
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x1f5): undefined reference to `xcb_get_file_descriptor'
...
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../libX11.a(ClDisplay.o): In function `XCloseDisplay':
(.text+0xbd): undefined reference to `xcb_disconnect'
collect2: ld returned 1 exit status
I guess something is missded, so I should link something more
but I can't find .o file in my file system.
(For example, OpenDis.o, xcb_disp.o, ClDisplay.o)
What should I do to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您缺少 libxcb 静态库。 http://xcb.freedesktop.org/
It looks like you're missing the libxcb static libraries. http://xcb.freedesktop.org/