LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   libusb compile error (https://www.linuxquestions.org/questions/programming-9/libusb-compile-error-349304/)

gabyx 08-02-2005 02:02 PM

libusb compile error
 
Hello, i want to compile a cpp file that call this functions:

usb_init();
for (bus = busses; bus; bus = bus->next) {
usb_find_busses();
usb_find_devices();

I am using this to compile:
gcc -Wall -W -I/a/b/c/include./libusb.a test1.cpp -o test1

but i have a lot of errors.

/tmp/ccseNamp.o(.text+0x1e): In function `main':
prueba1.cpp: undefined reference to `usb_init'
/tmp/ccseNamp.o(.text+0x34):test1.cpp: undefined reference to `usb_find_busses'
/tmp/ccseNamp.o(.text+0x39):test1.cpp: undefined reference to `usb_find_devices'
/tmp/ccseNamp.o(.text+0x55):test1.cpp: undefined reference to `usb_get_busses'
/tmp/ccseNamp.o(.text+0x1b4): In function `__static_initialization_and_destruction_0(int, int)':
prueba1.cpp: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccseNamp.o(.text+0x1e3): In function `__tcf_0':
prueba1.cpp: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccseNamp.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
-----------------------

I don't know where is the mistake. I think that it don't found libusb.a, so i copy that library to the same folder test1.

gabyx 08-02-2005 03:01 PM

I found the error. It was that gcc can't find functions in libusb.a because it was compiled with ansi c.

someone know how can i do to compile it.

keefaz 08-02-2005 03:04 PM

Try :
Code:

gcc -Wall -W test1.cpp -o test1 -lusb

gabyx 08-02-2005 03:22 PM

it doesn work. I want to try with libusb.so, but I don't know how to write it.

keefaz 08-02-2005 03:32 PM

Quote:

I want to try with libusb.so, but I don't know how to write it.
That's it :
Code:

-lusb
Where did you install libusb ? You may need to add -L/usr/lib if it is in /usr/lib

gabyx 08-02-2005 03:56 PM

It works!!!!!!!!!!!!!!!!!
gcc -Wall -W -L/usr/lib/ -lusb prueba1.cpp -o prueba1
thanks keefaz!!!!
--------
but it has other errors:
/tmp/ccThZICU.o(.text+0x1b4): In function `__static_initialization_and_destruction_0(int, int)':
test1.cpp: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccThZICU.o(.text+0x1e3): In function `__tcf_0':
test1.cpp: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccThZICU.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

keefaz 08-02-2005 04:29 PM

Try
Code:

g++ -Wall -W  prueba1.cpp -o prueba1 -L/usr/lib/ -lusb
I rarelly compile c++ though, maybe some other options are needed

gabyx 08-03-2005 07:57 AM

it works!!!!!!!!! thak you!!!!
I don't understand which is the diference between gcc and g++. I read http://gcc.gnu.org/onlinedocs/gcc-4...._Keyword-Index

but this is a lot of information together. Do you know other site that explain compilation options?

lowpro2k3 08-03-2005 10:20 AM

gcc is a C compiler, g++ is a C++ compiler

shiva_teknic 09-26-2005 05:11 AM

hello...
i installed busb-0.1.10a package.. i want to develop some simple applications with USB devices..
i execute the test programs... it executes fine...

now i copy the testfile testlibusb.c into another file name "testlib".. and try to compile it using the command
_______________________________________
gcc -Wall -W -L/usr/lib/ -lusb testlib.c -o testlib

but it gives some error...
_______________________________________

/tmp/ccME17sZ.o(.text+0x2db): In function `print_device':
: undefined reference to `usb_get_string_simple'
/tmp/ccME17sZ.o(.text+0x388): In function `print_device':
: undefined reference to `usb_get_string_simple'
/tmp/ccME17sZ.o(.text+0x522): In function `print_device':
: undefined reference to `usb_get_string_simple'
collect2: ld returned 1 exit status


kindly help me to compile that file... i think i might have used wrong commands...

thanks in advance

xwhbin 03-24-2010 04:38 AM

Quote:

Originally Posted by shiva_teknic (Post 1871242)
hello...
i installed busb-0.1.10a package.. i want to develop some simple applications with USB devices..
i execute the test programs... it executes fine...

now i copy the testfile testlibusb.c into another file name "testlib".. and try to compile it using the command
_______________________________________
gcc -Wall -W -L/usr/lib/ -lusb testlib.c -o testlib

but it gives some error...
_______________________________________

/tmp/ccME17sZ.o(.text+0x2db): In function `print_device':
: undefined reference to `usb_get_string_simple'
/tmp/ccME17sZ.o(.text+0x388): In function `print_device':
: undefined reference to `usb_get_string_simple'
/tmp/ccME17sZ.o(.text+0x522): In function `print_device':
: undefined reference to `usb_get_string_simple'
collect2: ld returned 1 exit status


kindly help me to compile that file... i think i might have used wrong commands...

thanks in advance

manybe,you can try:
gcc -Wall testlib.c -o testlib ./libusb.a


All times are GMT -5. The time now is 07:53 AM.