Libusb


chacali

Still Fresh
Joined
Jan 28, 2008
Messages
8
Hi everyone.

I've been searching on the net and on this forum without any result ... :(
Does anyone know how to integrate Libusb-0.1.12 in the open2x environnement ?

I was able to make it work on Ubuntu with the default g++ compiler (I just followed the install file instructions). But I don't know how to make it work with arm-open2x-linux-g++. When I "link"(not the correct word I think) the libusb.la library by writing -L"Location of the file" -lusb, the arm-open2x-linux-g++ compiler don't find it ??? But when i do the same with the classical g++ compiler it works perfectly.

That's the last step of a project in which I will use the gp2x as an oscilloscope. It's perfectly working on Ubuntu. As soon as I will finish it, I'll post the all project on this forum(circuit schematics in PCB format, usb PIC18F4550 protocol source code [firmware], oscilloscope source code [host application]...).

The version of Libusb that I use can be find here
The version of Open2x here

I'm using Ubuntu 7.10

.: Thank you :.

[I originally post this message in the wrong forum. I'm sorry about that :unsure: ]
 
Could be worth posting your makefile and details where the static (? don't recognise the extension .la personally..) usb library is..
Also post the output of your make..
I take it you've built the usb lib with open2x toolchain and the lib is the correct format..?
 
Thank you for your consideration (and sorry for the multiple topic post. I don't know what happened :unsure: ).

I m using open2x toolchain and I want to incorporate to it the libusb library.

I made it work on Ubuntu with the default compiler g++. After that, I tried to use it with arm-open2x-linux-g++ compiler. But when I try to compile it with the command:

hadi@Persocon:~$ /opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/arm-open2x-linux-g++ -L"usr/local/lib" -lusb -I"/home/hadi/Bureau/LIBUSB/libusb-0.1.12" -o /home/hadi/Bureau/Connection/connection.gpe /home/hadi/Bureau/Connection/connection.cpp

I get this error:

/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/../lib/gcc/arm-open2x-linux/4.1.1/../../../../arm-open2x-linux/bin/ld: cannot find -lusb

Here is the log files of the different step of the installation of libusb:

When I run the configure file I get this output:

hadi@Persocon:~/Bureau/LIBUSB/libusb-0.1.12$ sudo ./configure

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /bin/sed
checking for egrep... grep -E
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognise dependent libraries... pass_all
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking for g77... no
checking for f77... no
checking for xlf... no
checking for frt... no
checking for pgf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for f90... no
checking for xlf90... no
checking for pgf90... no
checking for epcf90... no
checking for f95... no
checking for fort... no
checking for xlf95... no
checking for ifc... no
checking for efc... no
checking for pgf95... no
checking for lf95... no
checking for gfortran... no
checking whether we are using the GNU Fortran 77 compiler... no
checking whether accepts -g... no
checking the maximum length of command line arguments... 32768
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if gcc static flag works... yes
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc supports -c -o file.o... yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
configure: creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC
checking if g++ PIC flag -fPIC works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
appending configuration tag "F77" to libtool
checking for what USB OS support... Linux
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ANSI C... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking whether gcc and cc understand -c and -o together... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for ANSI C header files... (cached) yes
checking for vprintf... yes
checking for _doprnt... no
checking for an ANSI C-conforming const... yes
checking whether byte ordering is bigendian... no
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for unistd.h... (cached) yes
checking values.h usability... yes
checking values.h presence... yes
checking for values.h... yes
checking for memmove... yes
checking for pkg-config... /usr/bin/pkg-config
checking if we should build the documentation... auto
checking for jade... no
checking for openjade... no
checking for Doxygen tools... checking for dot... not found
checking for doxygen... not found
configure: WARNING: Documentation build components not installed. sgml docs will not be built
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating libusb.spec
config.status: creating libusb-config
config.status: creating libusb.pc
config.status: creating tests/Makefile
config.status: creating README
config.status: creating INSTALL.libusb
config.status: creating usb.h
config.status: creating Doxyfile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing default commands


After that, I just run make and make install.

I can see that a lot of things are wrong (the whole think I guess :p ):
  • The compiler used by libusb seems to be the default g++ compiler and not arm-open2x-linux-g++.
  • A lot of path don t correspond to my configuration.
  • The build system type should be ARM or something but not i686-pc-linux-gnu
  • ...
I tried to modify it but I don't know where to begin. There should be something wrong with path and cross-compiling.

.: Thank you :.
 
try
CODE

./configure --host=arm-open2x-linux --target=arm-open2x-linux --build=`uname -m`



I dont think make install is going to work. You should once you have the lib compilied manually take the headers and lib and copy them into the correct folder in the open2x toolchain.
 
Ishibashi said:
I m using open2x toolchain and I want to incorporate to it the libusb library.

I made it work on Ubuntu with the default compiler g++. After that, I tried to use it with arm-open2x-linux-g++ compiler. But when I try to compile it with the command:

hadi@Persocon:~$ /opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/arm-open2x-linux-g++ -L"usr/local/lib" -lusb -I"/home/hadi/Bureau/LIBUSB/libusb-0.1.12" -o /home/hadi/Bureau/Connection/connection.gpe /home/hadi/Bureau/Connection/connection.cpp

I get this error:
/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/../lib/gcc/arm-open2x-linux/4.1.1/../../../../arm-open2x-linux/bin/ld: cannot find -lusb

Well you should build the usb lib with the cross-compiler... I think what Pickle says should help you there.
Also the line CODE
-L"usr/local/lib" -lusb
should beCODE
-L"/usr/local/lib" -lusb
if the usb.a file is in /usr/local/lib .....

Otherwise you could copy it to the lib directory under open2x eg on my setup /opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/
You could also copy the required usb header files to (again on my setup) /opt/open2x/gcc-4.1.1-glibc-2.3.6/include/
But (personally) I'd create local ../lib and ../include directories from where your application is and place any application-specific libraries and includes there rather than bloating the open2x area.

You would then need to add -I../include and -L../lib as required to your compile/link lines.
Here's a snippet from my makefile that may make what I'm trying to say clearer:
CODE
#### GP2X TOOLS
ARMCROSS = arm-open2x-linux-
ARMLDFLAGS = -static
ARMINCLUDES = -I/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/include/ \
-I/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/gcc/arm-open2x-linux/4.1.1/include/ \
-I/opt/open2x/allegro/include/ \
-I./ \
-I../loadpng-1.5/ \
-I../jpgalleg-2.5/include \
-I../glyph-keeper-0.28/include \
-DGK_NO_LEGACY -DGLYPH_TARGET=GLYPH_TARGET_ALLEGRO \
-L/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/

ARMCC = $(ARMCROSS)gcc -DGP2X -DMODMUSIC
ARMCXX = $(ARMCROSS)g++ -DGP2X -DMODMUSIC
ARMSTRIP = $(ARMCROSS)strip

ARMCFLAGS = $(ARMLDFLAGS) -O2 -Wall $(ARMINCLUDES)
ARMCXXFLAGS = -O2 -Wall $(ARMINCLUDES)

LOCLIB = ../lib
ARMLIB := -L$(LOCLIB) -laldmd -ldumb -lldpng -ljpgal -lgkalleg /opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libfreetype.a -lpng `/opt/gp2x/bin/allegro-config --libs ` -lz

abduction.gpe: abduction.cc .armobj/alien.o .armobj/humanoid.o .armobj/ship.o .armobj/titles.o .armobj/utils.o .armobj/instr.o
$(ARMCXX) $(ARMCFLAGS) -o $@ $^ $(ARMLIB)
$(ARMSTRIP) abduction.gpe
Note the LOCLIB & ARMLIB lines..
 
Last edited by a moderator:
Thank you for your help.

I think I ll use a make file to make my compilation easier [thanks for the advice :) ] and I ll try to compile the lib with the cross compiler.

If I get it work I ll inform you.

.: Thank you :.
 
Back
Top