Friday, April 19, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 7091  / 1 Year ago, tue, december 6, 2022, 6:31:11

I am trying to compile a program that uses libusb library in Ubuntu 12.04.



I have installed the libusb-1.0-0-dev. However, when I try to compile a program as below:



#include<usb.h>
#include<stdio.h>
#include<libusb-1.0/libusb.h>
int main()
{
libusb_init(NULL);
return 0;
}


It gives me an error saying



/tmp/ccb75YtE.o: In function 'main':
usb.c:(.text+0x11): undefined reference to 'libusb_init'
collect2: ld returned 1 exit status


I am using the command cc <file name> -lusb to compile it.
What could be the problem?


More From » compiling

 Answers
4

Try changing the -lusb to -lusb-1.0, like this:

$ cc <file name> -lusb-1.0


[#31878] Thursday, December 8, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ionodest

Total Points: 252
Total Questions: 122
Total Answers: 100

Location: Liechtenstein
Member since Tue, Apr 27, 2021
3 Years ago
;