0

I am working on a private project and have run into a linking error described below:

undefined reference to `gpioSetMode'
collect2: error: ld returned 1 exit status

I am using g++ and the terminal to compile my program. It was working yesterday without errors, but I attempted to make a new implementation which failed to compile. I deleted the implementation to return my program to it's original state and saved it (using nano text editor). then got this error in my program.

I ran the program in qt creator and am getting the same error.

The Makefile was adjusted to add the filepath to the gpio library folder. This was working before my last edit and has not been touched.

I'm back to guessing that maybe I left something out when trying to compile using

g++ filename.cpp

I sincerely appreciate your help with this!

1 Answer 1

0

You need to tell it to link the executable with the pigpio library.

Try g++ filename.cpp -lpigpio

1
  • Unfortunately this did not resolve my issue, the libraries were not seen by the compiler with the -l argument. I learned today that the cpp files were being compiled individually and an object file for each was being created, then the object files were being linked together :). This allowed the program to compile all of the cpp files together. Why it’s done this way I also can’t explain as I’m used to having this be accomplished with a header file. 🙈. I sincerely appreciate your time with answering this though I tried your solution many times!
    – winterx0
    Commented Feb 14 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.