You are not logged in.

#1 2013-01-11 13:42:02

jolivier
Member
Registered: 2012-05-30
Posts: 19

Cannot find -lusb-1.0

Hello all,

I'm trying to compile a software (https://github.com/todbot/blink1/tree/m … ommandline) and compilations fails due to:

/usr/bin/ld: cannot find -lusb-1.0

gcc `pkg-config libusb-1.0 --cflags` -fPIC -std=gnu99 -I ../hardware/firmware  -I./hidapi/hidapi -I./mongoose -g -static -g ./hidapi/libusb/hid.o blink1-lib.o  -v `pkg-config libusb-1.0 --libs` -lrt -lpthread -ldl blink1-tool.o -o blink1-tool
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/src/gcc-4.7.2/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --disable-ppl-version-check --disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu --enable-multilib --disable-libssp --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-checking=release
Thread model: posix
gcc version 4.7.2 (GCC)
COMPILER_PATH=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-I' '/usr/include/libusb-1.0' '-fPIC' '-std=gnu99' '-I' '../hardware/firmware' '-I' './hidapi/hidapi' '-I' './mongoose' '-g' '-static' '-g' '-v' '-o' 'blink1-tool' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/collect2 --build-id --hash-style=gnu -m elf_x86_64 -static -o blink1-tool /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/crt1.o /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/crti.o /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/crtbeginT.o -L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2 -L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../.. ./hidapi/libusb/hid.o blink1-lib.o -lusb-1.0 -lrt -lpthread -ldl blink1-tool.o --start-group -lgcc -lgcc_eh -lc --end-group /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/crtend.o /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/crtn.o
/usr/bin/ld: cannot find -lusb-1.0
collect2: error: ld returned 1 exit status

Although I have libusb-1.0:
locate libusb gives (among other stuff)

/usr/include/libusb-1.0
/usr/include/libusb-1.0/libusb.h
/usr/lib/libusb-0.1.so.4
/usr/lib/libusb-0.1.so.4.4.4
/usr/lib/libusb-1.0.so
/usr/lib/libusb-1.0.so.0
/usr/lib/libusb-1.0.so.0.1.0
/usr/lib/libusb.so
/usr/lib/pkgconfig/libusb-1.0.pc
/usr/lib/pkgconfig/libusb.pc
/usr/lib32/libusb-1.0.a
/usr/lib32/libusb-1.0.so
/usr/lib32/libusb-1.0.so.0
/usr/lib32/libusb-1.0.so.0.1.0
/usr/lib32/pkgconfig/libusb-1.0.pc

My libusb related installed packages are:

yaourt -Ss libusb|grep installed
core/libusb-compat 0.1.4-2 [installed]
core/libusbx 1.0.14-1 [installed]
extra/libgusb 0.1.4-1 [installed]
aur/lib32-libusb 1.0.9-1 [installed] (67)

What puzzles me is that I have a static lib for the 32bits version but not for the 64bits. If I add '-L/usr/lib32' to the linking command I get:

/usr/bin/ld: skipping incompatible /usr/lib32/libusb-1.0.a when searching for -lusb-1.0
/usr/bin/ld: cannot find -lusb-1.0
/usr/bin/ld: skipping incompatible /usr/lib32/librt.a when searching for -lrt
/usr/bin/ld: skipping incompatible /usr/lib32/libpthread.a when searching for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib32/libdl.a when searching for -ldl
/usr/bin/ld: skipping incompatible /usr/lib32/libc.a when searching for -lc

So it looks like it is only scanning static libs, which must be what the "-static" arg of the gcc command line does. My question is:
- Why do I have a static lib for the 32b libusb and not 64b?
What is then the recommended direction:
A.Find/make the static libusb 64b version and use it?
B.Change the makefile of this project to link dynamically against libusb?
C.Build in 32bits

I guess for A I would need to git clone libusb repo and do it myself.
I am a little bit affraid of B I'm not sure the build will support this (they use other libs like hidapi which depends on libusb)
C would be fine for me, I just need to find what to change in their makefile I guess.

Offline

#2 2013-01-11 14:21:03

Jub
Member
From: Secret Fort
Registered: 2009-11-18
Posts: 10
Website

Re: Cannot find -lusb-1.0

I'm no compiling expert, but I'm pretty sure if you want to compile a 32 bit application you should use the -m32 argument instead of linking to the lib32 directory. Also, I googled 'lusb-1.0' and it seems like there's an abundance of people having compilation issues of their own


I never know what to make my signature...

Offline

#3 2013-01-11 14:29:42

jolivier
Member
Registered: 2012-05-30
Posts: 19

Re: Cannot find -lusb-1.0

Thanks, this indeed works when switching to 32bits with -m32. Although I'm quite curious why it doesnt work in 64bits.
I also googled this a lot and found mostly people not having installed the dev version of the libusb which is on a different package on their distro, so the solutions I found were not applicable in my case.

Offline

Board footer

Powered by FluxBB