Having a problem linking an application statically...


Recommended Posts

So I'm trying to link a program statically, the first thing I did was go and download the source to a bunch of packages, edit them to include the --enable-static flag, recompiled and reinstalled them with the static files, great!

Now I'm trying to compile my own application statically, but I'm getting errors related to libxcb;

/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/../../../libxcb.a(xcb_auth.o): In function `get_authptr':
(.text+0x13c): undefined reference to `XauGetBestAuthByAddr'
/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/../../../libxcb.a(xcb_auth.o): In function `_xcb_get_auth_info':
(.text+0x34c): undefined reference to `XauDisposeAuth'
/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/../../../libxcb.a(xcb_auth.o): In function `_xcb_get_auth_info':
(.text+0x595): undefined reference to `XdmcpWrap'
/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/../../../libxcb.a(xcb_auth.o): In function `_xcb_get_auth_info':
(.text+0x5a9): undefined reference to `XauDisposeAuth'

 

I'm not overly sure how to go about dealing with this problem, searching gave me 2 people with similar problems and no replies to them what so ever.

My linker options are;

LINK          = g++
LFLAGS        = -Wl,-O1 -static
LIBS          = $(SUBLIBS) -L/usr/local/Qt-5.5.0-STATIC/lib -lQt5Widgets -lQt5SerialPort -L/usr/local/Qt-5.5.0-STATIC/plugins/platforms -lxcb-static -lqxcb -lQt5XcbQpa -L/QT/qt5/qtbase/src/plugins/platforms/xcb/xcb-static -lxcb -lxcb-static -lQt5PlatformSupport -lqtfreetype -ludev  -lQt5DBus -ldbus-1 -L/usr/local/Qt-5.5.0-STATIC/plugins/imageformats -lqdds -lqicns -lqico -lqjp2 -lqmng -lqtga -lqtiff -lqwbmp -lqwebp -lQt5Gui -lqtharfbuzzng -lQt5Core -lqtpcre -lm -ldl -lrt -lpthread

 

I read that someone suggested doing a grep on an nm on the libxcb file, the output shows the undefined functions are in libxcb.a;

nm /usr/lib/gcc/i686-pc-linux-gnu/4.9.2/../../../libxcb.a

<snip>

xcb_auth.o:
00000008 d authnames
00000000 d authnameslen
         U free
00000000 t get_authptr
         U gethostname
         U getpeername
00000200 t get_peer_sock_name
         U getpid
         U getsockname
         U malloc
         U memcmp
         U memcpy
00000000 b nonce.11070
00000004 b nonce_mutex.11071
         U pthread_mutex_lock
         U pthread_mutex_unlock
         U realloc
         U __snprintf_chk
         U __stack_chk_fail
         U time
         U XauDisposeAuth
         U XauGetBestAuthByAddr
000002e0 T _xcb_get_auth_info
         U XdmcpWrap

<snip>

 

So if the functions are there and are in the file it's complaining doesn't have them, I'm really not sure what to do, any advice?

Link to comment
Share on other sites

Actually nevermind I've managed to solve it myself, the U means unresolved meaning it's in an external library but you don't have it, then it's pain in the ######ing arse time to find all the libraries you're missing seeing as half the functions don't even link to the host library then it's a quick 2 minute job to recompile and reinstall those packages with static building on.

 

Hopefully this will help someone in the same problem because the empty threads with other people with the same problem didn't help me.

Link to comment
Share on other sites

This topic is now closed to further replies.