2013/10/8 Vanwynsberghe Charles <cvanw...@ens-cachan.fr>: > Hello, > > I've installed the very last version of libusbx on ubuntu (12.04 > here); and I have tried to "make" the examples in /examples and they > work great! > > However, how should I do to "gcc" my own program using libusbx? > Because when I do "gcc -c test.c -o test" with a code including > libusb.h, it says: > fatal error: libusb.h: no such file or directory > > Actually the error happens as well when I try to compile by myself one > of your examples (for example "gcc -c listdevs.c -o listdev"). So it > means I do something wrong but I didn't find in the documentation > something about how to compile. > > Must I add options to gcc? Or create a Makefile?
You need to tell gcc where libusb.h can be found and to link with libusb-1.0.so. You can do this manually or by using pkg-config, assuming that you have installed libusb normally so pkg-config can find the required .pc file. Otherwise you need to tell pkg-config where to find libusb-1.0.pc. Run "pkg-config --cflags libusb-1.0" and "pkg-config --libs libusb-1.0" to see what the output is in your case. You can also use backticks to include that in your gcc command like this: gcc `pkg-config --cflags libusb-1.0` listdevs.c -o listdevs `pkg-config --libs libusb-1.0` In my case this expands to gcc -I/usr/include/libusb-1.0 listdevs.c -o listdevs -lusb-1.0 You also need to remove the -c option from you gcc command because -c will only compile the source file, but doesn't not link it. -- Matthias Bolte http://photron.blogspot.com ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk _______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel