[Xcb] x11 static compile fail

Uli Schlachter psychon at znc.in
Fri Jun 10 18:34:32 UTC 2016


Am 07.06.2016 um 00:54 schrieb Rafi Rubin:
> Compiling a static x11 program fails using the output of:
> 	pkg-config --static --libs x11
> 
> The problem appears to be -lpthread shows up only before -lxcb.  There's
> something a bit odd in the pkg-config files.  x11.pc has pthread in
> Libs.private, and xcb has pthread-stubs in Requires.private.  However
> pthread-stubs isn't actually adding the -l flag to the output, and the
> resulting ordering breaks my build.
> 
> So, which package should be correct: x11 or xcb?  Should the
> pthread-stubs have -lpthread in Libs.private?
> 
> 
> My versions:
> ibxcb1-dev 1.11.1-1
> libx11-dev 2:1.6.3-1
> libpthread-stubs0-dev 0.3-4

I'm on debian testing and my
/usr/lib/x86_64-linux-gnu/pkgconfig/pthread-stubs.pc contains "Libs:". If I
download pthread-stubs and hack it with the following patch, then your static
build works for me.

diff --git a/configure.ac b/configure.ac
index ef300ad..af00a14 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,7 +38,6 @@ m4_divert_pop([KILL])

 dnl Check which functions we need to provide aliases for.
 PKG_CONFIG_LIBS=
-AC_CHECK_FUNCS(funclist, [], [PKG_CONFIG_LIBS='-L${libdir} -lpthread-stubs'])

 AC_SUBST([PKG_CONFIG_LIBS])
 AM_CONDITIONAL(BUILD_LIB, test "x$PKG_CONFIG_LIBS" != x)



And indeed:

$ nm --dynamic /lib/x86_64-linux-gnu/libc.so.6 | grep pthread_cond_signal
00000000000f50d0 T pthread_cond_signal
000000000011ee60 T pthread_cond_signal

So why does this fail static compilation? I looked for libc.a and ran:

$ ar x /usr/lib/x86_64-linux-gnu/libc.a
$ for x in *.o ; do readelf -a $x ; done | grep pthread_cond_signal
$

So the dynamic version of libc provides the pthread symbols (and thus
pthread-stubs figures out it is not needed) while the static version does not.

Report a bug against libc on debian? What do others think?

Cheers,
Uli
-- 
“Some people are worth melting for.” - Olaf


More information about the Xcb mailing list