OpenWrt Forum Archive

Topic: can't compile a program that uses libusb

The content of this topic has been archived on 16 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I've written a custom program based on libusb. It works fine on my laptop (running gentoo linux), but my goal is to make it work on my asus wl-500g Deluxe.

I'm trying to cross-compile it, but  it doesn't work, because i'm not that good at cross-compiling and writing Makefiles. I'm learning...

The compile line in my Makefile looks like:

readusb: usb2.c
       $(COMPILE_PATH)mipsel-linux-uclibc-gcc -I $(LIB_PATH) -I $(INCLUDE_PATH) -O2 -Wall -o readusb usb2.c -L$(LIB_PATH) -lusb

where :
INCLUDE_PATH   is   [...]/openwrt/staging_dir_mipsel/include/
LIB_PATH  is   [...]/openwrt/build_mipsel/libusb-0.1.10a/

I did this because my program includes <usb.h> which is in LIB_PATH, and {<time.h>, <stdio.h>, ...}, which are in the standard include path.

I'm getting the error (edited after farnz's reply):

[...]/openwrt/staging_dir_mipsel/lib/gcc/mipsel-linux-uclibc/3.4.4/../../../../mipsel-linux-uclibc/bin/ld : cannot find -lusb

Could you please point me out what i am doing wrong?
Thanks!

(Last edited by laurentgedm on 24 Mar 2006, 16:09)

laurentgedm wrote:

The compile line in my Makefile looks like:

readusb: usb2.c
       $(COMPILE_PATH)mipsel-linux-uclibc-gcc -I $(LIB_PATH) -I $(INCLUDE_PATH) -O2 -Wall -o readusb usb2.c -L$(LIB_PATH) -lusb

I'm getting the error:

[...]/openwrt/staging_dir_mipsel/lib/gcc/mipsel-linux-uclibc/3.4.4/../../../../mipsel-linux-uclibc/bin/ld : cannot find -lsub

Could you please point me out what i am doing wrong?
Thanks!

The error does not match up to the line in the makefile; it looks like you've put -lsub instead of -lusb.

Ooops, sorry... i guess i typed it too fast when posting the error.

But, anyway, the error is "cannot find -lusb".

So there is something wrong with the inclusion of the library.

Ok, i found the error.

LIB_PATH  is   [...]/openwrt/build_mipsel/libusb-0.1.10a/

It has to be [...]/openwrt/staging_dir_mipsel/usr/lib

Also, -L has to be followed by a white space... while -l not.

The discussion might have continued from here.