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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-02-2005, 03:02 PM
|
#1
|
LQ Newbie
Registered: Aug 2005
Posts: 8
Rep:
|
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.
|
|
|
08-02-2005, 04:01 PM
|
#2
|
LQ Newbie
Registered: Aug 2005
Posts: 8
Original Poster
Rep:
|
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.
|
|
|
08-02-2005, 04:04 PM
|
#3
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,784
|
Try :
Code:
gcc -Wall -W test1.cpp -o test1 -lusb
|
|
|
08-02-2005, 04:22 PM
|
#4
|
LQ Newbie
Registered: Aug 2005
Posts: 8
Original Poster
Rep:
|
it doesn work. I want to try with libusb.so, but I don't know how to write it.
|
|
|
08-02-2005, 04:32 PM
|
#5
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,784
|
Quote:
I want to try with libusb.so, but I don't know how to write it.
|
That's it :
Where did you install libusb ? You may need to add -L/usr/lib if it is in /usr/lib
|
|
|
08-02-2005, 04:56 PM
|
#6
|
LQ Newbie
Registered: Aug 2005
Posts: 8
Original Poster
Rep:
|
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
|
|
|
08-02-2005, 05:29 PM
|
#7
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,784
|
Try
Code:
g++ -Wall -W prueba1.cpp -o prueba1 -L/usr/lib/ -lusb
I rarelly compile c++ though, maybe some other options are needed
|
|
|
08-03-2005, 08:57 AM
|
#8
|
LQ Newbie
Registered: Aug 2005
Posts: 8
Original Poster
Rep:
|
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?
|
|
|
08-03-2005, 11:20 AM
|
#9
|
Member
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340
Rep:
|
gcc is a C compiler, g++ is a C++ compiler
|
|
|
09-26-2005, 06:11 AM
|
#10
|
LQ Newbie
Registered: Sep 2005
Location: Bangalore,india
Distribution: Redhat9
Posts: 4
Rep:
|
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
|
|
|
03-24-2010, 05:38 AM
|
#11
|
LQ Newbie
Registered: Feb 2010
Location: china
Posts: 5
Rep:
|
Quote:
Originally Posted by shiva_teknic
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 04:17 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|