Statically linking to libX11

Michel Dänzer michel at daenzer.net
Wed May 8 09:04:07 UTC 2019


On 2019-05-07 8:14 p.m., Vanessa McHale wrote:
> Hi all,
> 
> I am trying to cross-compile xmobar for ARM and unfortunately my C
> cross-compiler uses a different libc version; I figured static linking
> would give me a usable binary. Unfortunately, trying to cross-compile
> yields:
> 
> Linking
> /home/vanessa/programming/haskell/done/xmobar-vanessa/dist-newstyle/build/aarch64-linux/ghc-8.6.4/xmobar-vanessa-0.1.0.0/x/xmobar/build/xmobar/xmobar
> ...
> /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:
> /usr/local/lib/aarch64-linux-gnu-ghc-8.6.4/rts/libHSrts.a(Linker.o): in
> function `internal_dlopen':
> 
> /home/vanessa/cross/ghc-8.6.4/rts/Linker.c:600:0: error:
>      warning: Using 'dlopen' in statically linked applications requires
> at runtime the shared libraries from the glibc version used for linking
> /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:
> /home/vanessa/.cabal/store/ghc-8.6.4/network-3.1.0.0-b60cf17d11d7eda024959ae28f710f94d7565bcd8e3372f04f32d2600769c2c1/lib/libHSnetwork-3.1.0.0-b60cf17d11d7eda024959ae28f710f94d7565bcd8e3372f04f32d2600769c2c1.a(HsNet.o):
> in function `hsnet_getaddrinfo':
> HsNet.c:(.text+0x10): warning: Using 'getaddrinfo' in statically linked
> applications requires at runtime the shared libraries from the glibc
> version used for linking
> /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:
> /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(xcb_io.o):
> in function `require_socket':
> 
> /tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_io.c:68:0: error:
>      undefined reference to `xcb_take_socket'
> /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:
> /usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(xcb_io.o):
> in function `poll_for_event':
> 
> /tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_io.c:245:0: error:
>      undefined reference to `xcb_poll_for_event'

Static linking requires linking all of libX11's dependencies statically
as well.

 pkg-config --libs --static x11

should print the linker flags needed for that.


-- 
Earthling Michel Dänzer               |              https://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the xorg mailing list