Problem compiling a libusb program
Dear coders,
I am trying to compile a C program that includes the following code: Code:
#include "libusb.h" Quote:
I have managed to get control under Windows, but that works invoking a DLL, a different story. I need to switch to linux, and actually in the end crosscompile it for an embedded PowerPC based linux system. But at the moment, in order to go in steps, just compiling for testing in a full Linux PC would be a progress... I hope I have worked correctly the include dependencies with libusb, but the libusb test program compiles and runs fine. I am a very basic C programmer, I am more in Fortran (!), Basic, Matlab environments and I am not fully understanding this program structure I have not written myself, therefore after many attempts and googleing I feel a bit helpless at the moment and I hope in a kick forward from you! I understand it should lie in some missed variable declaration, but this were I stop... I thank you in advance for any help! Sneezie |
Hi.
What linux distribution do you use? How did you install libusb? In Ubuntu you can just Code:
sudo apt-get install libusb-dev Code:
#include <usb.h> Code:
$ dpkg -L libusb-dev | grep .h$ Code:
gcc test.c -lusb |
Thank you firstfire! :)
Quote:
Actually, I have already installed libusb, both by apt-get (as a second smarter move) and (firstly) by compiling the downloaded distribution (can this have messed things a bit?). It seems it got installed in /usr/local/lib, which I added to lib.so.conf and then I run ldconfig. I was actually including libusb, since with usb I got referencing error messages for the send_message command. And then in the search of some solution I tried to include libusb and got stuck with it, since it was also compiling fine the example program of the libusb library. Your suggestion has therefore solved the original problem I posted, but now if I include lines including the "send_message" command, which are in the rest of the program I have not posted to the forum, I get the errors: Code:
usb@.c:(.text+0x1fb): undefined reference to `send_command' Therefore, it seems this time the problem lies in the dependencies to libusb which are not correctly addressed. You managed to compile the program from the USBMicro site, if I understood well, therefore the problem is on my side, I reckon... I am (have been) working on that, but if you have a hint, I would be grateful! I bet the crosscompiling step will be even tougher (I already managed to crosscompile with buildroot other programs on a couple of platforms, but libusb so far is the one giving me headaches... I am not 'that' experienced and when things get bumpy for any reason I get lost). Thank you again! :) Sneezie |
Hi.
Could you please post complete code and gcc command line? Your last error message looks strange because function `send_command' is defined in the code I compiled: Code:
int send_command( struct usb_dev_handle *handle, char *command, int comLen, int resLen ) |
Quote:
I was trying compiling the code in chunks and I forgot to put the send_command definition back in place! :redface: Obviously the compiler was complaining! :doh: Compilation successful! On to the crosscompiler now! I think I tried all the combinations, but once I got in trouble I began to swirl in nonsense... You put all pieces in the right order! Thank you really very much! Sneezie :) P.S.-Unfortunately this is not a promise that I will not get into trouble again... |
All times are GMT -5. The time now is 05:06 PM. |