PORTS Forum
Ports and Interfaces => USB => Topic started by: Martin on July 26, 2014, 10:12:50 pm
-
Hi All.
I'm still learning how to do things in a Linux environment, and I want to compile the generic_hid example using Eclipse. I can do this without issue from the command line, but I cant figure out how to pass the -lusb-1.0 option to Eclipse.
On the command line I use:
gcc -o ghid generic_hid.c -I/usr/include/libusb-1.0/ -lusb-1.0
which works fine.
Can anyone help out with this? I noticed a search on this site using eclipse as a key work did not reveal much. Is anyone else using Eclipse to do the same?
Cheers
m.b
-
Add the path to the project’s Include paths.
-
hmm... I wasn't expecting that... -lusb, or -lusb-1.0 still wont work within eclipse. Fair enough though, a path in the windows world is the fix for all ailments for sure.
I came across a post which advised someone to plug in the "pkg-config --libs libusb" command and then use its output “-lusb” to plug back into the linker,.. tried that still failed. Any ideas?
m.b
-
By "failed," do you mean that you were able to include the path without error but the project didn't compile? What was the error?
-
Hi Jan, thanks for your input even though its not directly a USB issue.
I've just (as I write this) successfully compiled my eclipse project). Long story short I was actually correctly adding the -lusb linker command, and also correctly adding the path to the library files. But,...... lesson to oneself, don't add “-lusb” to the libraries section within C++ build settings, but leave out the “-l” in other words add it as “usb” or “usb-1.0”, it seems the “-l” is added internally. At least this is what worked.
Who knew? not me.
BTW:
The error was,
../src/generic_hid.cpp:78: undefined reference to `libusb_init'
and the same type of error for all libusb function your example uses.
Let me know if you want me to elaborate on my steps taken.
Cheers
m.b
-
Glad you got it working; thanks for reporting back.