• 11095阅读
  • 8回复

高人指点一下,qt静态链接的问题!!!!!!!! [复制链接]

上一主题 下一主题
离线mytears
 
只看楼主 倒序阅读 楼主  发表于: 2009-08-08
请求高人指点

我希望编译完全静态链接没有依赖的程序

我开始是用qt sdk开发的

后来静态编译安装了qt-x11-opensource-src-4.5.2

使用qmake 和make之后编译的程序ldd查看没有qt的库依赖了

而系统库与c++库还是动态链接的

网上查阅资料后

我在makefile之中的LIBS 后加上-static

但是却无法编译成功 make后提示一大串

(.text+0x1380): undefined reference to `pcre_compile2'
/usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libglib-2.0.a(gregex.o): In function `g_regex_new':
(.text+0x13a9): undefined reference to `pcre_fullinfo'
/usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libglib-2.0.a(gregex.o): In function `g_regex_new':
(.text+0x140d): undefined reference to `pcre_study'
/usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libglib-2.0.a(gregex.o): In function `g_regex_new':
(.text+0x14ef): undefined reference to `pcre_config'
/usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libglib-2.0.a(gregex.o): In function `g_regex_new':
(.text+0x1506): undefined reference to `pcre_config'
/usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libglib-2.0.a(gregex.o): In function `g_regex_new':
(.text+0x154a): undefined reference to `pcre_fullinfo'
/usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libglib-2.0.a(gregex.o): In function `get_matched_substring_number':
(.text+0x1b60): undefined reference to `pcre_get_stringtable_entries'
/usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libglib-2.0.a(gregex.o): In function `get_matched_substring_number':
(.text+0x1bdb): undefined reference to `pcre_get_stringnumber'
/usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libglib-2.0.a(gregex.o): In function `g_match_info_next':
(.text+0x20e5): undefined reference to `pcre_exec'
collect2: ld 返回 1
make: *** [complexdialog] 错误 1

ldd的效果

linux-gate.so.1 => (0xb7fd9000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0xb7f98000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0xb7f21000)
libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0xb7ee2000)
libSM.so.6 => /usr/lib/libSM.so.6 (0xb7ed9000)
libICE.so.6 => /usr/lib/libICE.so.6 (0xb7ec1000)
libXrender.so.1 => /usr/lib/libXrender.so.1 (0xb7eb7000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0xb7e8a000)
libXext.so.6 => /usr/lib/libXext.so.6 (0xb7e7a000)
libX11.so.6 => /usr/lib/libX11.so.6 (0xb7d8a000)
libz.so.1 => /lib/libz.so.1 (0xb7d74000)
libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0xb7d6e000)
librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb7d65000)
libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0xb7cad000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7ca9000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7c8f000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7ba0000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7b7a000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7b6b000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7a08000)
libpcre.so.3 => /lib/libpcre.so.3 (0xb79d5000)
libuuid.so.1 => /lib/libuuid.so.1 (0xb79d0000)
libexpat.so.1 => /usr/lib/libexpat.so.1 (0xb79a9000)
libXau.so.6 => /usr/lib/libXau.so.6 (0xb79a5000)
libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb798b000)
/lib/ld-linux.so.2 (0xb7fda000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb7985000)

离线freshmanzkj
只看该作者 1楼 发表于: 2009-08-10
我也不会
离线mytears
只看该作者 2楼 发表于: 2009-08-11
回 1楼(freshmanzkj) 的帖子
也谢谢了

呵呵

继续求助啊
离线snowdream
只看该作者 3楼 发表于: 2009-08-11
QQ:273247606
希望与大家一起交流QT~
离线freshmanzkj
只看该作者 4楼 发表于: 2009-08-11
引用第3楼snowdream于2009-08-11 14:14发表的  :
静态编译Qt4.4.3
http://blog.csdn.net/yang_hui1986527/archive/2009/07/27/4384901.aspx
希望对你有帮助~

我照着上面的做了,不行。
不知道是不是版本不同的问题
离线80437
只看该作者 5楼 发表于: 2009-08-11
错误显示你在link过程中缺少其他需要的静态库
离线gaintele

只看该作者 6楼 发表于: 2009-10-21
我的也出了这错误啊
在makefile中加了-static然后再make就一堆错误:
g++ -Wl,-O1 -Wl,-rpath,/usr/local/Trolltech/Qt-4.5.3/lib -Wl,-rpath,/usr/local/Trolltech/Qt-4.5.3/lib -o ErrInjectTool .obj/release-static/errinjecttool.o .obj/release-static/main.o .obj/release-static/moc_errinjecttool.o    -L/usr/local/Trolltech/Qt-4.5.3/lib -lQtGui -L/usr/local/Trolltech/Qt-4.5.3/lib -L/usr/X11R6/lib -pthread -lpng -lfreetype -lSM -lICE -pthread -pthread -lXrender -lfontconfig -lXext -lX11 -lQtCore -lz -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread -static
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(CrGlCur.o): In function `open_library':
(.text+0x3b): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/Trolltech/Qt-4.5.3/lib/libQtCore.a(qfsfileengine_unix.o): In function `QFSFileEngine::owner(QAbstractFileEngine::FileOwner) const':
qfsfileengine_unix.cpp:(.text+0xabe): warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libglib-2.0.a(gutils.o): In function `g_get_any_init_do':
(.text+0x14be): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libglib-2.0.a(gutils.o): In function `g_get_any_init_do':
(.text+0x14b1): warning: Using 'setpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libglib-2.0.a(gutils.o): In function `g_get_any_init_do':
(.text+0x14c6): warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(GetDflt.o): In function `GetHomeDir':
(.text+0xa9): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/Trolltech/Qt-4.5.3/lib/libQtGui.a(qapplication_x11.o): In function `sm_performSaveYourself(QSessionManagerPrivate*)':
qapplication_x11.cpp:(.text+0x8a25): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libICE.a(icetrans.o): In function `_IceTransSocketOpen':
(.text+0x15ac): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libICE.a(icetrans.o): In function `_IceTransGetPeerNetworkId':
(.text+0x279d): warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libICE.a(icetrans.o): In function `_IceTransSocketUNIXConnect':
(.text+0x29fb): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libICE.a(icetrans.o): In function `_IceTransSocketINETConnect':
(.text+0x30ca): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcfreetype.o): In function `FcFreeTypeQueryFace':
(.text+0x245e): undefined reference to `FT_Get_BDF_Property'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcfreetype.o): In function `FcFreeTypeQueryFace':
(.text+0x248f): undefined reference to `FT_Get_BDF_Property'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcfreetype.o): In function `FcFreeTypeQueryFace':
(.text+0x27a3): undefined reference to `FT_Get_X11_Font_Format'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcfreetype.o): In function `FcFreeTypeQueryFace':
(.text+0x27e8): undefined reference to `FT_Get_BDF_Property'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcfreetype.o): In function `FcFreeTypeQueryFace':
(.text+0x2812): undefined reference to `FT_Get_BDF_Property'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcfreetype.o): In function `FcFreeTypeQueryFace':
(.text+0x28e4): undefined reference to `FT_Get_BDF_Property'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcfreetype.o): In function `FcFreeTypeQueryFace':
(.text+0x2a6c): undefined reference to `FT_Get_BDF_Property'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcfreetype.o): In function `FcFreeTypeQueryFace':
(.text+0x2ac1): undefined reference to `FT_Get_BDF_Property'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcfreetype.o):(.text+0x2aea): more undefined references to `FT_Get_BDF_Property' follow
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcxml.o): In function `FcConfigMessage':
(.text+0x25a): undefined reference to `XML_GetCurrentLineNumber'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcxml.o): In function `FcConfigMessage':
(.text+0x2e7): undefined reference to `XML_GetCurrentLineNumber'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcxml.o): In function `FcConfigParseAndLoad':
(.text+0x1c60): undefined reference to `XML_ParserCreate'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcxml.o): In function `FcConfigParseAndLoad':
(.text+0x1ca5): undefined reference to `XML_SetUserData'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcxml.o): In function `FcConfigParseAndLoad':
(.text+0x1cbd): undefined reference to `XML_SetDoctypeDeclHandler'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcxml.o): In function `FcConfigParseAndLoad':
(.text+0x1cd5): undefined reference to `XML_SetElementHandler'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcxml.o): In function `FcConfigParseAndLoad':
(.text+0x1ce5): undefined reference to `XML_SetCharacterDataHandler'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcxml.o): In function `FcConfigParseAndLoad':
(.text+0x1cfc): undefined reference to `XML_GetBuffer'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcxml.o): In function `FcConfigParseAndLoad':
(.text+0x1d3c): undefined reference to `XML_ParseBuffer'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcxml.o): In function `FcConfigParseAndLoad':
(.text+0x1d64): undefined reference to `XML_ParserFree'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcxml.o): In function `FcConfigParseAndLoad':
(.text+0x2047): undefined reference to `XML_GetErrorCode'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libfontconfig.a(fcxml.o): In function `FcConfigParseAndLoad':
(.text+0x204f): undefined reference to `XML_ErrorString'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(ClDisplay.o): In function `XCloseDisplay':
(.text+0xbe): undefined reference to `xcb_disconnect'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(OpenDis.o): In function `OutOfMemory':
(.text+0x3fa): undefined reference to `xcb_disconnect'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(OpenDis.o): In function `XOpenDisplay':
(.text+0x7e2): undefined reference to `xcb_get_setup'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(OpenDis.o): In function `XOpenDisplay':
(.text+0xc29): undefined reference to `xcb_get_maximum_request_length'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_lock.o): In function `_XPutXCBBuffer':
(.text+0xdd): undefined reference to `xcb_get_request_sent'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_lock.o): In function `_XPutXCBBuffer':
(.text+0x30e): undefined reference to `xcb_get_request_sent'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_lock.o): In function `_XPutXCBBuffer':
(.text+0x33d): undefined reference to `xcb_send_request'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_lock.o): In function `_XGetXCBBuffer':
(.text+0x568): undefined reference to `xcb_get_request_sent'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_lock.o): In function `_XGetXCBBuffer':
(.text+0x57b): undefined reference to `xcb_connection_has_error'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_lock.o): In function `_XCBUnlockDisplay':
(.text+0x6ad): undefined reference to `xcb_xlib_unlock'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_lock.o): In function `_XCBUnlockDisplay':
(.text+0x6e0): undefined reference to `xcb_get_request_sent'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_lock.o): In function `_XCBLockDisplay':
(.text+0x78d): undefined reference to `xcb_xlib_lock'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x94): undefined reference to `xcb_parse_display'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x147): undefined reference to `xcb_connect_to_display_with_auth_info'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x165): undefined reference to `xcb_get_file_descriptor'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x18e): undefined reference to `xcb_generate_id'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x199): undefined reference to `xcb_connection_has_error'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x1c3): undefined reference to `xcb_connect'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_io.o): In function `wait_or_poll_for_event':
(.text+0x3ef): undefined reference to `xcb_wait_for_event'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_io.o): In function `wait_or_poll_for_event':
(.text+0x414): undefined reference to `xcb_poll_for_event'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_io.o): In function `process_responses':
(.text+0x4c3): undefined reference to `xcb_connection_has_error'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_io.o): In function `process_responses':
(.text+0x519): undefined reference to `xcb_xlib_unlock'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_io.o): In function `process_responses':
(.text+0x543): undefined reference to `xcb_xlib_lock'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_io.o): In function `process_responses':
(.text+0x5de): undefined reference to `xcb_poll_for_reply'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_io.o): In function `_XReply':
(.text+0x890): undefined reference to `xcb_xlib_unlock'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_io.o): In function `_XReply':
(.text+0x8bb): undefined reference to `xcb_wait_for_reply'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_io.o): In function `_XAllocIDs':
(.text+0xb60): undefined reference to `xcb_generate_id'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_io.o): In function `_XIDHandler':
(.text+0xb98): undefined reference to `xcb_generate_id'
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/libX11.a(xcb_io.o): In function `_XSend':
(.text+0xc45): undefined reference to `xcb_flush'
collect2: ld returned 1 exit status
make: *** [ErrInjectTool] Error 1

高人出来指点啊
离线rqzrqh

只看该作者 7楼 发表于: 2009-10-21
没有指明gcc需要的库的路径吧
离线wato
只看该作者 8楼 发表于: 2009-11-09
愁死个人了.............................
快速回复
限100 字节
 
上一个 下一个