LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-02-2005, 02:02 PM   #1
gabyx
LQ Newbie
 
Registered: Aug 2005
Posts: 8

Rep: Reputation: 0
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.
 
Old 08-02-2005, 03:01 PM   #2
gabyx
LQ Newbie
 
Registered: Aug 2005
Posts: 8

Original Poster
Rep: Reputation: 0
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.
 
Old 08-02-2005, 03:04 PM   #3
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,454

Rep: Reputation: 96
Try :
Code:
gcc -Wall -W test1.cpp -o test1 -lusb
 
Old 08-02-2005, 03:22 PM   #4
gabyx
LQ Newbie
 
Registered: Aug 2005
Posts: 8

Original Poster
Rep: Reputation: 0
it doesn work. I want to try with libusb.so, but I don't know how to write it.
 
Old 08-02-2005, 03:32 PM   #5
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,454

Rep: Reputation: 96
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
 
Old 08-02-2005, 03:56 PM   #6
gabyx
LQ Newbie
 
Registered: Aug 2005
Posts: 8

Original Poster
Rep: Reputation: 0
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
 
Old 08-02-2005, 04:29 PM   #7
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,454

Rep: Reputation: 96
Try
Code:
g++ -Wall -W  prueba1.cpp -o prueba1 -L/usr/lib/ -lusb
I rarelly compile c++ though, maybe some other options are needed
 
Old 08-03-2005, 07:57 AM   #8
gabyx
LQ Newbie
 
Registered: Aug 2005
Posts: 8

Original Poster
Rep: Reputation: 0
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?
 
Old 08-03-2005, 10:20 AM   #9
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
gcc is a C compiler, g++ is a C++ compiler
 
Old 09-26-2005, 05:11 AM   #10
shiva_teknic
LQ Newbie
 
Registered: Sep 2005
Location: Bangalore,india
Distribution: Redhat9
Posts: 4

Rep: Reputation: 0
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
 
Old 03-24-2010, 04:38 AM   #11
xwhbin
LQ Newbie
 
Registered: Feb 2010
Location: china
Posts: 5

Rep: Reputation: 0
Quote:
Originally Posted by shiva_teknic View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help me --- interrupt_read() in libusb shiva_teknic Programming 0 09-27-2005 08:17 AM
libusb Digikam question alexm1 Linux - Hardware 0 06-06-2005 04:52 PM
error while loading shared libraries: libusb-0.1.4 Ross Clement Fedora 2 11-10-2004 10:53 AM
compile error: #error unknown processor family kmack2001 Linux - Newbie 0 02-14-2004 11:52 AM
libUSB install Dutch3 Linux - Newbie 1 04-30-2002 07:15 AM


All times are GMT -5. The time now is 06:56 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration