views:

26

answers:

1

I built X11R5 libs statically on a 32-bit Fedora Core 9 machine. Then I built an app which uses X11 and linked it statically. So far, so good. ldd reports it's a statically-linked app. I can run it locally just fine. But when I copy it over to a 64-bit FC9 machine, it fails as follows:

assistant.static: xcb_io.c:228: _XSend: Assertion `!dpy->xcb->request_extra' failed.
Aborted

When I run strace, it seems to be trying to open libXfixes.so:

...
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libXfixes.so", O_RDONLY)     = -1 ENOENT (No such file or directory)
open("/usr/lib/libXfixes.so", O_RDONLY) = -1 ENOENT (No such file or directory)
munmap(0xf7bf9000, 123447)              = 0
open("libXfixes", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 8
fstat64(0x8, 0xff86a9e8)                = 0
mmap2(NULL, 123447, PROT_READ, MAP_PRIVATE, 8, 0) = 0xfffffffff7bf9000
close(8)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libXfixes", O_RDONLY)        = -1 ENOENT (No such file or directory)
open("/usr/lib/libXfixes", O_RDONLY)    = -1 ENOENT (No such file or directory)
munmap(0xf7bf9000, 123447)              = 0
open("libXfixes.so.4", O_RDONLY)        = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 8
fstat64(0x8, 0xff86a9e8)                = 0
mmap2(NULL, 123447, PROT_READ, MAP_PRIVATE, 8, 0) = 0xfffffffff7bf9000
close(8)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libXfixes.so.4", O_RDONLY)   = -1 ENOENT (No such file or directory)
open("/usr/lib/libXfixes.so.4", O_RDONLY) = -1 ENOENT (No such file or directory)
munmap(0xf7bf9000, 123447)              = 0
open("libXfixes", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 8
fstat64(0x8, 0xff86a9e8)                = 0
mmap2(NULL, 123447, PROT_READ, MAP_PRIVATE, 8, 0) = 0xfffffffff7bf9000
close(8)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libXfixes", O_RDONLY)        = -1 ENOENT (No such file or directory)
open("/usr/lib/libXfixes", O_RDONLY)    = -1 ENOENT (No such file or directory)
munmap(0xf7bf9000, 123447)              = 0
write(2, "assistant.static: xcb_io.c:228: "..., 85assistant.static: xcb_io.c:228: _XSend: Assertion `!dpy->xcb->request_extra' failed.

I don't understand why a statically-linked application would be trying to open shared X libs. Shouldn't everything needed to run the app be included via static linking (except of course for any Linux system calls the app makes, which need to be handled externally).

Thanks for any explanations!

A: 

X11 dynamically loads libraries and it's may be loading the 64 bits libraries instead of the 32 bits version.

It's normal to load modules at runtime - like when loading plugins or drivers. And since the modules are dynamically linked to X11 itself, you're going to find yourself in a mess.

Personally, I never had luck linking X11 statically - is is really needed for you?

Vitor Py
It's an application that is going out to customers, who may be on various flavors of Linux. So the goal is to minimize builds. The other apps, which are not X11-based, have no problem running statically on many flavors of Linux, but maybe that won't be the case with the X11-based apps.
Dave Wade-Stein
@Dave Wade-Stein Yes, I understand. I also do ship closed source on Linux - it's a pain. I never ship static binaries - also due to licensing restrictions on libraries. You may want to check this question and answer: http://stackoverflow.com/questions/3214168/linking-statically-with-glibc-and-libstdc/3214232#3214232 The solution for me is: link dynamically and target the Linux Standard Base.
Vitor Py