The problem is that you're linking the object files, not just compiling them.
Make sure that you only compile the files, don't link them! You do that using the -c
option. Do not use the -l
option, you don't want to link anything at this stage. So:
gcc -c -o usb_comm.o usb_comm.c gcc -c -o hex2bin.o hex2bin.c gcc -c -o hex_read.o hex_read.c gcc -c -o crc32.o crc32.c
(I omitted the -I
flags to save space here.)
Then finally link all those object files into a shared library, and link against usb-1.0:
gcc -shared -o libhello.so usb_comm.o hex2bin.o hex_read.o crc32.o -lusb-1.0
You should use a Makefile though for this. Or, even better, use a proper build system, like CMake, which is very easy to use. It's provided by all common Linux distros, so simply install it with the package manager (it it's not installed already), and read a quick tutorial on it.