LDFLAGS+= -fPIC and LIBS += -lrt -lpthread doesn't work via debian/rules at Launchpad

Asked by Boris Derzhavets

Please view PPA https://launchpad.net/~bderzhavets/+archive/qemu-usb5
For second package i specify in debian/rules :-

LDFLAGS = -shared -fPIC,-Wl,--as-needed
LIBS += -lrt -lpthread

Build
https://launchpadlibrarian.net/81034779/buildlog_ubuntu-oneiric-amd64.usbredir_0.3.1-1ubuntu3_FAILEDTOBUILD.txt.gz

with error

cc -shared -shared -fPIC,-Wl,--as-needed -L../usbredirparser -L../usbredirhost -L../usbredirparser -L../usbredirhost -Wl,-soname,libusbredirhost.so.1 -o libusbredirhost.so.1 usbredirhost.o ../usbredirparser/libusbredirparser.so -lusb-1.0
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libusb-1.0.a(libusb_1_0_la-core.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libusb-1.0.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libusbredirhost.so] Error 1
make[2]: Leaving directory `/build/buildd/usbredir-0.3.1/usbredirhost'
make[1]: *** [all] Error 1
make[1]: Leaving directory `/build/buildd/usbredir-0.3.1'
dh_auto_build: make -j1 returned exit code 2
make: *** [build] Error 2

Build

https://launchpadlibrarian.net/81034789/buildlog_ubuntu-oneiric-i386.usbredir_0.3.1-1ubuntu3_BUILDING.txt.gz

succeeds, but with warning

dpkg-shlibdeps: warning: symbol pthread_mutexattr_init used by debian/libusbredir/usr/lib/libusbredirhost.so.1 found in none of the libraries.
dpkg-shlibdeps: warning: symbol pthread_mutex_trylock used by debian/libusbredir/usr/lib/libusbredirhost.so.1 found in none of the libraries.
dpkg-shlibdeps: warning: symbol pthread_mutexattr_destroy used by debian/libusbredir/usr/lib/libusbredirhost.so.1 found in none of the libraries.
dpkg-shlibdeps: warning: symbol pthread_mutexattr_settype used by debian/libusbredir/usr/lib/libusbredirhost.so.1 found in none of the libraries.
dpkg-shlibdeps: warning: symbol clock_gettime used by debian/libusbredir/usr/lib/libusbredirhost.so.1 found in none of the libraries.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Boris Derzhavets
Solved:
Last query:
Last reply:
Revision history for this message
Julian Taylor (jtaylor) said :
#1

Thank you for taking the time to report this issue and helping to make Ubuntu better. Examining the information you have given us, this does not appear to be a bug report so we are closing it and converting it to a question in the support tracker. We understand the difficulties you are facing, but it would make more sense to raise problems you are having in the support tracker at https://answers.launchpad.net/ubuntu or ask at http://askubuntu.com/ if you are uncertain if they are bugs. For help on reporting bugs, see https://help.ubuntu.com/community/ReportingBugs.

in this case your build system is broken in many places. e.g. usbredirserver/Makefile uses -Wl,-rpath-link which requires you to use pkg-config --static libusb-1.0 to get all libraries and libusb-1.0 must be built with -fPIC which it is currently not in the packages in your ppa.

Revision history for this message
Boris Derzhavets (bderzhavets) said :
#2

I've updated

usbredirhost/Makefile as follows :

override CPPFLAGS += $(shell pkg-config --cflags libusb-1.0-rc1)
LIBS_libusbredirhost = $(shell pkg-config --libs libusb-1.0-rc1)

usbredirserver/Makefile as follows

override CPPFLAGS += $(shell pkg-config --cflags libusb-1.0-rc1)
LIBS = $(shell pkg-config --libs libusb-1.0-rc1)

debian/control

Build-Depends: debhelper (>= 8.0.0),
               autotools-dev,
               pkg-config,
               quilt (>= 0.40),
               libusb-1.0-rc1,
               libusb-1.0-rc1-dev
System is expected libusb-1.0-rc1 installed on Ubuntu , not to be just in PPA ( it's there)

https://launchpadlibrarian.net/81106021/buildlog_ubuntu-oneiric-i386.usbredir_0.3.1-1ubuntu2_FAILEDTOBUILD.txt.gz

It just cannot find library,suggesting to change PKG_CONFIG_PATH.

Revision history for this message
Boris Derzhavets (bderzhavets) said :
#3

That's a mistake. I used name of package instead of library.
Disregard previous statement.

Revision history for this message
Boris Derzhavets (bderzhavets) said :
#4

> libusb-1.0 must be built with -fPIC which it is currently not in the packages in your ppa.

I believe libusb-1.0 ( v. 1.0.9-rc1) is in package libusb-1.0-rc1 which is in the PPA.

Revision history for this message
Boris Derzhavets (bderzhavets) said :
#5

Procedure bellow locally run just fine on beta-2 +

Per Hans de Goede

*** Step 1 Building libusb ***

First of all you will need libusb from git for now, hopefully there will soon be an offfical 1.0.9 release you can use instead. To build libusb from git do:

git clone git://people.freedesktop.org/~jwrdegoede/libusb
cd libusb
git checkout -B for109 origin/for109
./autogen.sh
./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
make -j2
sudo make install

*** Step 2 building usbredir ***

Next you will need to build usbredir itself for the usbredirparser and usbredirhost libraries, download it here, then do:

tar xvfj usbredir-0.3.1.tar.bz2
cd usbredir-0.3.1
make -j2 PREFIX=/usr LIBDIR=/usr/lib
sudo make PREFIX=/usr LIBDIR=/usr/lib install

*********************************

Attempt to package into https://launchpad.net/~bderzhavets/+archive/libusb-test2
gives the same results as above

Revision history for this message
Boris Derzhavets (bderzhavets) said :
#6

All what we have locally after Step 1 :

root@boris-P5Q3:/# find . -name "libusb*.so*" -print
./lib/libusb-0.1.so.4
./lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0
./lib/x86_64-linux-gnu/libusb-1.0.so.0.0.0
./lib/x86_64-linux-gnu/libusb-1.0.so
./lib/x86_64-linux-gnu/libusb-1.0.so.0
./lib/libusb-0.1.so.4.4.4
./usr/lib/libusbmuxd.so.1
./usr/lib/libusb-0.1.so.4
./usr/lib/libusbmuxd.so.1.0.7
./usr/lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0
./usr/lib/x86_64-linux-gnu/libusb-1.0.so
./usr/lib/x86_64-linux-gnu/libusb-1.0.so.0

Builder goes to :-
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libusb-1.0.a(libusb_1_0_la-core.o)
which one i cannot find locally

And after Step 2 :

./usr/lib64/libusbredirparser.so.0
./usr/lib64/libusbredirhost.so
./usr/lib64/libusbredirparser.so
./usr/lib64/libusbredirhost.so.1

Revision history for this message
Boris Derzhavets (bderzhavets) said :
#7

> libusb-1.0 must be built with -fPIC which it is currently not in the packages in your ppa.

That's right . Creating symlink :

https://launchpadlibrarian.net/81372747/buildlog_ubuntu-oneiric-amd64.libusb-1.0_2%3A1.0.9-1ubuntu7_BUILDING.txt.gz

chroot-autobuild/build/buildd/libusb-1.0_1.0.9-1ubuntu7_amd64.deb:
drwxr-xr-x root/root 0 2011-09-29 00:25 ./
drwxr-xr-x root/root 0 2011-09-29 00:25 ./lib/
drwxr-xr-x root/root 0 2011-09-29 00:25 ./lib/x86_64-linux-gnu/
-rw-r--r-- root/root 55576 2011-09-29 00:25 ./lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0
drwxr-xr-x root/root 0 2011-09-29 00:25 ./usr/
drwxr-xr-x root/root 0 2011-09-29 00:25 ./usr/share/
drwxr-xr-x root/root 0 2011-09-29 00:25 ./usr/share/doc/
drwxr-xr-x root/root 0 2011-09-29 00:25 ./usr/share/doc/libusb-1.0/
-rw-r--r-- root/root 541 2011-09-27 18:35 ./usr/share/doc/libusb-1.0/README.Debian
-rw-r--r-- root/root 726 2011-09-27 18:28 ./usr/share/doc/libusb-1.0/README
-rw-r--r-- root/root 1289 2011-09-27 18:35 ./usr/share/doc/libusb-1.0/copyright
-rw-r--r-- root/root 612 2011-09-27 18:28 ./usr/share/doc/libusb-1.0/changelog.gz
-rw-r--r-- root/root 5833 2011-09-29 00:09 ./usr/share/doc/libusb-1.0/changelog.Debian.gz
drwxr-xr-x root/root 0 2011-09-29 00:25 ./usr/lib/
drwxr-xr-x root/root 0 2011-09-29 00:25 ./usr/lib/x86_64-linux-gnu/
lrwxrwxrwx root/root 0 2011-09-29 00:25 ./lib/x86_64-linux-gnu/libusb-1.0.so.0 -> libusb-1.0.so.0.1.0
lrwxrwxrwx root/root 0 2011-09-29 00:25 ./usr/lib/libusb-1.0.so -> /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0 <==

doesn't help

Revision history for this message
Boris Derzhavets (bderzhavets) said :
#8

Please, view https://launchpad.net/~bderzhavets/+archive/libusb-test4

libusb-1.0 (2:1.0.9-2ubuntu7) oneiric; urgency=high

  * Build libusb 1.0.9 via git clone git://people.freedesktop.org/~jwrdegoede/libusb
    - added libusb-1.0.links for /usr/lib/libusb-1.0.so
    - CFLAGS = -fPIC -Wall

usbredir (0.3.1-1ubuntu1) oneiric; urgency=high

  * Initial release.
  - Changed CFLAGS += -fPIC -Wall -g -O$(if $(findstring noopt,$(DEB_BUILD_OPTIONS)),0,2)
  - Make.rules updated with -fPIC
 -- Boris Derzhavets <email address hidden> Thu, 29 Sep 2011 16:47:54 +0400

have been built OK for 64-bit and 32-bit

However, log:-
https://launchpadlibrarian.net/81452052/buildlog_ubuntu-oneiric-amd64.usbredir_0.3.1-1ubuntu1_BUILDING.txt.gz

contains

dpkg-shlibdeps: warning: symbol pthread_mutexattr_init used by debian/libusbredir/usr/lib/libusbredirhost.so.1 found in none of the libraries.
dpkg-shlibdeps: warning: symbol pthread_mutex_trylock used by debian/libusbredir/usr/lib/libusbredirhost.so.1 found in none of the libraries.
dpkg-shlibdeps: warning: symbol pthread_mutexattr_destroy used by debian/libusbredir/usr/lib/libusbredirhost.so.1 found in none of the libraries.
dpkg-shlibdeps: warning: symbol pthread_mutexattr_settype used by debian/libusbredir/usr/lib/libusbredirhost.so.1 found in none of the libraries.
dpkg-shlibdeps: warning: symbol clock_gettime used by debian/libusbredir/usr/lib/libusbredirhost.so.1 found in none of the libraries.

Regardless debian/rules has LIBS += -lrt -lpthread

I would consider this already as system bug

Revision history for this message
Julian Taylor (jtaylor) said :
#9

no the Makefile.rules does not use the LIBS variable, instead it uses LIBS_somename.
Either fix that to use LIBS or do this:

--- usbredir-0.3.1.orig/usbredirhost/Makefile
+++ usbredir-0.3.1/usbredirhost/Makefile
@@ -1,6 +1,6 @@
 override CPPFLAGS += $(shell pkg-config --cflags libusb-1.0)

-LIBS_libusbredirhost = $(shell pkg-config --libs libusb-1.0)
+LIBS_libusbredirhost = $(shell pkg-config --libs libusb-1.0) -lrt -lpthread

 USBREDIRHOST_OBJS = usbredirhost.o
 USBREDIRHOST_DEPS = $(USBREDIRHOST_OBJS)

Revision history for this message
Boris Derzhavets (bderzhavets) said :
#10

Thank you very much.
Issue is closed