Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
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.
|
 |
|
01-25-2015, 12:51 PM
|
#1
|
LQ Newbie
Registered: Jan 2015
Posts: 14
Rep: 
|
Linking libusb-1.0 to mycfile.c fails
Despite downloading and compiling libusb-1.0 to /usr/local, to know exactky where it is, gcc still can't find it;
gcc -o usb -L/usr/local/lib -llibusb-1.0.so -I/usr/local/include myusbcfile.c
gives;
usbtest.c:4:15: error: storage size of ‘brd_ftdi’ isn’t known
libusb_device brd_ftdi;
^
usbtest.c:5:22: error: storage size of ‘brd_ftdi_handle’ isn’t known
libusb_device_handle brd_ftdi_handle;
^
usbtest.c:6:16: error: storage size of ‘context’ isn’t known
libusb_context context;
^
This clearly indicates gcc can't find the library, tried different forms of this command, everyone giving this error.
|
|
|
01-26-2015, 06:19 AM
|
#2
|
Senior Member
Registered: Feb 2009
Posts: 1,727
|
this error message is not complete,
but to me it looks like you miss an include in your source rather than a linker problem
|
|
|
01-26-2015, 06:47 AM
|
#3
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,246
|
looks like an #include "libusb.h" or similar is missing in your c file. it is not about a library but a header file.
Last edited by pan64; 01-26-2015 at 06:49 AM.
|
|
|
01-26-2015, 08:19 AM
|
#4
|
LQ Newbie
Registered: Jan 2015
Posts: 14
Original Poster
Rep: 
|
Nope I've included it with #include <libusb.h> and since /usr/local/include is in the standard include path I use <>. I tested with citations ("") also but same error there.
I only declared three variables in libusb so it couldn't be so much other errors. And the error message is complete in my point of view, since it was all I got.
|
|
|
01-26-2015, 08:26 AM
|
#5
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,246
|
/usr/local/include is not the standard include path, therefore you need to use ". You need to show us the c file you wrote, otherwise we can only guess....
|
|
|
01-26-2015, 09:17 AM
|
#6
|
LQ Newbie
Registered: Jan 2015
Posts: 14
Original Poster
Rep: 
|
#include <stdio.h>
#include "libusb-1.0/libusb.h"
libusb_device brd_ftdi;
libusb_device_handle brd_ftdi_handle;
libusb_context context;
/*
//libusb_init (libusb_context **);
libusb_init (&context);
libusb_get_device_list(context, &brd_ftdi);
libusb_open(brd_ftdi, brd_ftdi_handle);
//libusb_exit(struct libusb_context *);
libusb_exit(context);
*/
-----------------------
As you can see I've included libusb.h properly. The function calls are commented since they give even more errors which concludes the same thing. So to track down the error I made it simple to only declare 3 variables.
Last edited by BombaD; 01-26-2015 at 09:19 AM.
|
|
|
01-26-2015, 09:50 AM
|
#7
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,246
|
actually I still do not know how that libusb was installed, you need to check the location of the file libusb.h. probably it is /usr/local/include/libusb-1.0/libusb.h, but probably not.
Also it was mentioned that is not the full error message, please post the whole output of the command (and also the command itself).
|
|
|
01-27-2015, 09:48 AM
|
#9
|
LQ Newbie
Registered: Jan 2015
Posts: 14
Original Poster
Rep: 
|
Except not putting my code in brackets I've followed every guideline in the posting-information.
I compiled libusb-1.0.9 which I downloaded from libusb.org with
Code:
./configure --prefix=/usr/local
make
sudo make install
The include file is located is /usr/local/include/libusb-1.0/libusb.h
Code:
~$ ls -l /usr/local/include
Code:
total 4
drwxr-xr-x 2 root root 4096 jan 24 19:58 libusb-1.0
The libfiles are located in /usr/local/lib
Code:
ls -l /usr/local/lib
Code:
total 1156
-rw-r--r-- 1 root root 266594 jan 19 14:57 libftd2xx.a
lrwxrwxrwx 1 root root 34 jan 19 15:56 libftd2xx.so -> /usr/local/lib/libftd2xx.so.1.1.12
-rwxr-xr-x 1 root root 223388 jan 19 14:57 libftd2xx.so.1.1.12
-rw-r--r-- 1 root root 418662 jan 24 19:58 libusb-1.0.a
-rwxr-xr-x 1 root root 953 jan 24 19:58 libusb-1.0.la
lrwxrwxrwx 1 root root 19 jan 24 19:58 libusb-1.0.so -> libusb-1.0.so.0.1.0
lrwxrwxrwx 1 root root 19 jan 24 19:58 libusb-1.0.so.0 -> libusb-1.0.so.0.1.0
-rwxr-xr-x 1 root root 255620 jan 24 19:58 libusb-1.0.so.0.1.0
drwxr-xr-x 2 root root 4096 jan 24 19:58 pkgconfig
My C-file usbtest.c:
Code:
#include <stdio.h>
#include <libusb-1.0/libusb.h>
libusb_device brd_ftdi;
libusb_device_handle brd_ftdi_handle;
libusb_context context;
/*
//libusb_init (libusb_context **);
libusb_init (&context);
libusb_get_device_list(context, &brd_ftdi);
libusb_open(brd_ftdi, brd_ftdi_handle);
//libusb_exit(struct libusb_context *);
libusb_exit(context);
*/
also tried with;
Code:
#include "libusb-1.0/libusb.h"
compiled with;
Code:
gcc -o usb -L/usr/local/lib -llibusb-1.0.so -I/usr/local/include usbtest.c
There should be no other conflicts since the other folders with libusb is not in standard path and the path is explicitly given to gcc.
|
|
|
01-27-2015, 10:44 AM
|
#10
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,246
|
and what is the full output of the last command?
please add -Wall. This is the correct syntax I think:
gcc -Wall -o usb -I/usr/local/include usbtest.c -L/usr/local/lib -lusb-1.0
|
|
|
01-28-2015, 09:04 AM
|
#11
|
LQ Newbie
Registered: Jan 2015
Posts: 14
Original Poster
Rep: 
|
Oh, sorry... running
Code:
$ gcc -o usb -L/usr/local/lib -llibusb-1.0.so -I/usr/local/include usbtest.c
gives;
Code:
usbtest.c:4:15: error: storage size of ‘brd_ftdi’ isn’t known
libusb_device brd_ftdi;
^
usbtest.c:5:22: error: storage size of ‘brd_ftdi_handle’ isn’t known
libusb_device_handle brd_ftdi_handle;
^
usbtest.c:6:16: error: storage size of ‘context’ isn’t known
libusb_context context;
^
and with -Wall;
Code:
gcc -Wall -o usb -L/usr/local/lib -llibusb-1.0.so -I/usr/local/include usbtest.c
gives;
Code:
usbtest.c:4:15: error: storage size of ‘brd_ftdi’ isn’t known
libusb_device brd_ftdi;
^
usbtest.c:5:22: error: storage size of ‘brd_ftdi_handle’ isn’t known
libusb_device_handle brd_ftdi_handle;
^
usbtest.c:6:16: error: storage size of ‘context’ isn’t known
libusb_context context;
^
Didn't work, and it is the whole error message. When I ran with the function calls, I got several other errors as well saying the functions were not defined so the only conclusion I can make is that it don't somehow finds the declarations. I haven't checked the sources, only the docs but I assume from the docs (where all those functions and variables were listed) they are declared somewhere in my copy of libusb-1.0.9.
Last edited by BombaD; 01-28-2015 at 09:13 AM.
Reason: State that this didn't work either
|
|
|
01-28-2015, 12:53 PM
|
#12
|
Senior Member
Registered: Feb 2009
Posts: 1,727
|
because they have incomplete types
you do not use them as 'value object', just as pointers for communication with libusb
Code:
#include <stdio.h>
#include <libusb-1.0/libusb.h>
libusb_device * brd_ftdi;
libusb_device_handle * brd_ftdi_handle;
libusb_context * context;
usage for example
Code:
libusb_context*ctx = 0;
libusb_init(&ctx); //ponter to a pointer!!!
the full definition that tells the compiler the size are in a different header,
and the libusb devs decided that you do not need to know about these internals, thats ok
|
|
|
01-29-2015, 07:23 PM
|
#13
|
LQ Newbie
Registered: Jan 2015
Posts: 14
Original Poster
Rep: 
|
It seems that using pointers yields a slighty different message; with no errors except that gcc still can't find the library despite trying -lusb-1.0.so flag:
Code:
$ gcc -Wall -o usb -L/usr/local/lib -llibusb-1.0.so -I/usr/local/include usbtest.c
usbtest.c: In function ‘main’:
usbtest.c:6:17: warning: unused variable ‘context’ [-Wunused-variable]
libusb_context* context;
^
usbtest.c:5:24: warning: unused variable ‘brd_ftdi_handle’ [-Wunused-variable]
libusb_device_handle** brd_ftdi_handle;
^
usbtest.c:4:18: warning: unused variable ‘brd_ftdi’ [-Wunused-variable]
libusb_device*** brd_ftdi;
^
/usr/bin/ld: cannot find -llibusb-1.0.so
collect2: error: ld returned 1 exit status
Without pointer:
Code:
$ gcc -Wall -o usb -L/usr/local/lib -llibusb-1.0.so -I/usr/local/include usbtest.c
usbtest.c: In function ‘main’:
usbtest.c:4:15: error: storage size of ‘brd_ftdi’ isn’t known
libusb_device brd_ftdi;
^
usbtest.c:5:22: error: storage size of ‘brd_ftdi_handle’ isn’t known
libusb_device_handle brd_ftdi_handle;
^
usbtest.c:6:16: error: storage size of ‘context’ isn’t known
libusb_context context;
^
usbtest.c:6:16: warning: unused variable ‘context’ [-Wunused-variable]
usbtest.c:5:22: warning: unused variable ‘brd_ftdi_handle’ [-Wunused-variable]
libusb_device_handle brd_ftdi_handle;
^
usbtest.c:4:15: warning: unused variable ‘brd_ftdi’ [-Wunused-variable]
libusb_device brd_ftdi;
^
And here's the code:
Code:
#include <stdio.h>
#include <libusb-1.0/libusb.h>
int main(void) {
libusb_device* brd_ftdi;
libusb_device_handle** brd_ftdi_handle;
libusb_context* context;
return 0;
}
But nevertheless gcc clearly states it cannot find the library despite using -lusb-1.0.so.
Last edited by BombaD; 01-29-2015 at 07:25 PM.
|
|
|
01-30-2015, 02:01 AM
|
#14
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,246
|
I told you already: you need to enter: -lusb-1.0 - no lib and no .so required.
|
|
|
02-04-2015, 12:18 PM
|
#15
|
LQ Newbie
Registered: Jan 2015
Posts: 14
Original Poster
Rep: 
|
That did it, thx. I ran this command 3 times and not working according to .bash_history. Must have run it previously without the pointers.
Command:
Code:
gcc -o usb -L/usr/local/lib -lusb-1.0 -I/usr/local/include usbtest.c
(-Wall option did also work)
usbtest.c
Code:
#include <stdio.h>
#include <libusb-1.0/libusb.h>
int main() {
libusb_device* brd_ftdi;
libusb_device_handle** brd_ftdi_handle;
libusb_context* context;
return 0;
}
Last edited by BombaD; 02-04-2015 at 12:21 PM.
|
|
|
All times are GMT -5. The time now is 06:32 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
|
|