Bug 97383

Summary: underlinking: undefined reference to 'XGetPointerControl' [...]
Product: Spice Reporter: Michał Górny <mgorny>
Component: spice-gtkAssignee: Spice Bug List <spice-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=585118
Whiteboard:
i915 platform: i915 features:
Attachments: Build log (for current git version)
Patch adding necessary linkage

Description Michał Górny 2016-08-17 13:43:23 UTC
Created attachment 125848 [details]
Build log (for current git version)

When attempting to build spice-gtk with the GNU gold linker, the build fails with the series of errors:

libtool: link: x86_64-pc-linux-gnu-gcc-5.4.0 -march=k8-sse3 -mcx16 -msahf --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -O2 -pipe -frecord-gcc-switches -Wl,-O1 -Wl,--hash-style=gnu -o .libs/spicy spicy-spicy.o spicy-spicy-connect.o spicy-spice-cmdline.o -pthread  -Wl,--as-needed ./.libs/libspice-client-gtk-3.0.so /tmp/portage/net-misc/spice-gtk-9999/work/spice-gtk-9999/src/.libs/libspice-client-glib-2.0.so ./.libs/libspice-client-glib-2.0.so -lcelt051 /usr/lib64/libopus.so -ljpeg -lz -llz4 -lpixman-1 -lssl -lcrypto -lusb-1.0 -lusbredirhost -lusbredirparser -lgthread-2.0 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lepoxy -lm -pthread
./.libs/libspice-client-gtk-3.0.so: error: undefined reference to 'XGetPointerControl'
./.libs/libspice-client-gtk-3.0.so: error: undefined reference to 'XChangePointerControl'
./.libs/libspice-client-gtk-3.0.so: error: undefined reference to 'XkbGetMap'
./.libs/libspice-client-gtk-3.0.so: error: undefined reference to 'XkbGetNames'
./.libs/libspice-client-gtk-3.0.so: error: undefined reference to 'XkbFreeKeyboard'
./.libs/libspice-client-gtk-3.0.so: error: undefined reference to 'XListExtensions'
./.libs/libspice-client-gtk-3.0.so: error: undefined reference to 'XFreeExtensionList'
collect2: error: ld returned 1 exit status
distcc[5868] ERROR: compile (null) on localhost failed
make[4]: *** [Makefile:1151: spicy] Error 1

This indicates that the library is using some X11 APIs directly but not linking to appropriate X11 libraries.
Comment 1 Michał Górny 2016-08-17 14:03:49 UTC
It seems that some of the calls are conditional to GDK_WINDOWING_X11, and some to HAVE_X11_XKBLIB_H. The latter also lacks an appropriate --enable switch making it an automagic dependency.
Comment 2 Michał Górny 2016-08-17 14:24:21 UTC
Created attachment 125849 [details] [review]
Patch adding necessary linkage

Here's a patch that fixes the issue for me. It's based on the existing code, finds whether X11 backend is available and enforces libX11 linkage (via x11.pc) appropriately.
Comment 3 Marc-Andre Lureau 2016-09-21 08:36:06 UTC
Fixed in
https://cgit.freedesktop.org/spice/spice-gtk/commit/?id=11dcc17b0a01e9f06a3cc6dbb6051326779677e3

and subsequent commits

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.