<div dir="ltr">The problem is that static archives can't declare implicit dependencies: if you link dynamically, libX11.so will implicitly depend on libxcb.so, but if you link statically you must also explicitly link against -lxcb.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 1, 2019 at 5:00 PM Vanessa McHale <<a href="mailto:vanessa.mchale@iohk.io">vanessa.mchale@iohk.io</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
I'm trying to cross-compile xmobar for aarch64-linux-gnu. The cross<br>
compiler that comes with my version of Ubuntu works with a later GLIBC<br>
than the host platform, so I figured I'd make a static executable<br>
instead - this approach had worked with e.g. cabal-install.<br>
<br>
Unfortunately, I get the following:<br>
<br>
Resolving dependencies...<br>
Build profile: -w ghc-8.6.4 -O1<br>
In order, the following will be built (use -v for more details):<br>
- xmobar-vanessa-0.1.0.0 (exe:xmobar) (first run)<br>
Preprocessing executable 'xmobar' for xmobar-vanessa-0.1.0.0..<br>
Building executable 'xmobar' for xmobar-vanessa-0.1.0.0..<br>
Linking<br>
/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<br>
...<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/local/lib/aarch64-linux-gnu-ghc-8.6.4/rts/libHSrts.a(Linker.o): in<br>
function `internal_dlopen':<br>
<br>
/home/vanessa/cross/ghc-8.6.4/rts/Linker.c:600:0: error:<br>
warning: Using 'dlopen' in statically linked applications requires<br>
at runtime the shared libraries from the glibc version used for linking<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/home/vanessa/.cabal/store/ghc-8.6.4/network-3.1.0.0-b60cf17d11d7eda024959ae28f710f94d7565bcd8e3372f04f32d2600769c2c1/lib/libHSnetwork-3.1.0.0-b60cf17d11d7eda024959ae28f710f94d7565bcd8e3372f04f32d2600769c2c1.a(HsNet.o):<br>
in function `hsnet_getaddrinfo':<br>
HsNet.c:(.text+0x10): warning: Using 'getaddrinfo' in statically linked<br>
applications requires at runtime the shared libraries from the glibc<br>
version used for linking<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(xcb_io.o):<br>
in function `require_socket':<br>
<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_io.c:68:0: error:<br>
undefined reference to `xcb_take_socket'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(xcb_io.o):<br>
in function `poll_for_event':<br>
<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_io.c:245:0: error:<br>
undefined reference to `xcb_poll_for_event'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_io.c:243: undefined<br>
reference to `xcb_poll_for_queued_event'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(xcb_io.o):<br>
in function `poll_for_response':<br>
<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_io.c:284:0: error:<br>
undefined reference to `xcb_poll_for_reply64'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(xcb_io.o):<br>
in function `_XSend':<br>
<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_io.c:499:0: error:<br>
undefined reference to `xcb_writev'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(xcb_io.o):<br>
in function `_XEventsQueued':<br>
<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_io.c:364:0: error:<br>
undefined reference to `xcb_connection_has_error'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(xcb_io.o):<br>
in function `_XReadEvents':<br>
<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_io.c:441:0: error:<br>
undefined reference to `xcb_connection_has_error'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_io.c:400: undefined<br>
reference to `xcb_wait_for_event'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(xcb_io.o):<br>
in function `_XAllocIDs':<br>
<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_io.c:549:0: error:<br>
undefined reference to `xcb_generate_id'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(xcb_io.o):<br>
in function `_XReply':<br>
<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_io.c:609:0: error:<br>
undefined reference to `xcb_wait_for_reply64'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(ClDisplay.o):<br>
in function `XCloseDisplay':<br>
<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/ClDisplay.c:71:0: error:<br>
undefined reference to `xcb_disconnect'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(OpenDis.o):<br>
in function `OutOfMemory':<br>
<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/OpenDis.c:705:0: error:<br>
undefined reference to `xcb_disconnect'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(OpenDis.o):<br>
in function `XOpenDisplay':<br>
<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/OpenDis.c:255:0: error:<br>
undefined reference to `xcb_get_setup'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/OpenDis.c:498: undefined<br>
reference to `xcb_get_maximum_request_length'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/lib/../lib/libX11.a(xcb_disp.o):<br>
in function `_XConnectXCB':<br>
<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_disp.c:69:0: error:<br>
undefined reference to `xcb_parse_display'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_disp.c:76: undefined<br>
reference to `xcb_connect_to_display_with_auth_info'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_disp.c:81: undefined<br>
reference to `xcb_get_file_descriptor'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_disp.c:84: undefined<br>
reference to `xcb_generate_id'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_disp.c:92: undefined<br>
reference to `xcb_connection_has_error'<br>
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld:<br>
/tmp/cpkg-2c6d48cdbb4678ca/libX11-1.6.7/src/xcb_disp.c:78: undefined<br>
reference to `xcb_connect'<br>
collect2: error: ld returned 1 exit status<br>
`aarch64-linux-gnu-gcc' failed in phase `Linker'. (Exit code: 1)<br>
<br>
I looked in libX11.a with<br>
<br>
nm /usr/aarch64-linux-gnu/lib/libX11.a | rg 'xcb_take_socket'<br>
<br>
which yields<br>
<br>
U xcb_take_socket<br>
<br>
<br>
which, as I understand, means that something is screwed up in the X11<br>
static linking (but I know less about systems programming and linkers<br>
than Haskell).<br>
<br>
Does anyone know how to fix such a problem?<br>
<br>
Cheers,<br>
Vanessa McHale<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>brandon s allbery kf8nh</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a></div></div></div></div></div>