Reputation: 11017
Using the Makefile provided by the Pi GPIO library, I made the libpigpio.so shard object using:
# from line 119 in make file
make libpigpio.so
The shared object is created fine. The Makefile first created the pigpio.o
object, then the command.o
object, and links them together as a shared object. So far so good!
I wrote a very small main function that calls the gpioInitialise
and gpioGetPWMfrequency
.
It doesn't really matter which functions, what's important is they are defined in pigpio.h
and written in pigpio.c
.
Meaning the shared object should have them.
The compile command for my code is:
gcc -Wall -pthread -fpic -L. -lpigpio -o drive drive.c
Still I get the undefined reference error to both those functions.
It makes no sense! If it didn't find the shared object, it would reject the command. I also tried it -l:libpigpio.so
and still the same problem.
I am compiling directly on the Rpi A+ (not using a cross compiler). So it should work!
What am I missing here?
Upvotes: 0
Views: 1205
Reputation: 3616
It is a link order question. Please try the flowing command.
gcc drive.c -Wall -pthread -fpic -o drive -L. -lpigpio
you can read Why does the order in which libraries are linked sometimes cause errors in GCC? for more details.
Upvotes: 2