Posts: 286
Joined: Mon Jun 11, 2018 11:22 am

Re: wiringPi undefined Reference

Tue Jun 11, 2019 8:49 am

Hussey wrote:
Mon Jun 10, 2019 4:56 pm
I downloaded the wiringPi library directly as tar.gz file. I extracted it and then I build it. I hope i followed correct steps. Then I am trying to compile and build the simple blink program but it shows the same error of undefined reference. I am also adding the -lwiringpi in my compile line but it is still not working. Please help urgently! I am really annoyed.
Which Pi do you have,
and which operating system ? Jessie? Stretch? Lite or not Lite?

User avatar
Posts: 1229
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: wiringPi undefined Reference

Wed Jun 12, 2019 4:20 am

Hi Gordon,

Just wanted to say I have had success using your GPIO library. Much better than the rpi.gpio C library I started off with. I have added a couple utility functions to make it work better with an interpreter.


Posts: 2
Joined: Sun Jun 16, 2019 2:55 pm
Location: Hungary

Re: wiringPi undefined Reference

Sun Jun 16, 2019 4:25 pm

Hi Guys!

I have a strange wirePi 'undefined Reference' problem with Anjuta IDE on Raspberry Pi 3 B+ with Ubuntu MATE (Ubuntu 18.04.2 LTS - arm 64bit, MATE 1.20.1) while gpio and gcc from terminal work well...

The problem:

When I start a simple (or any other) c (or c++) project with Anjuta and I try to run or build the blink example program
#include <wiringPi.h>
int main (void)
wiringPiSetup () ;
pinMode (0, OUTPUT) ;
for (int n=0; n <100; n=n+1)
digitalWrite (0, HIGH) ; delay (200) ;
digitalWrite (0, LOW) ; delay (200) ;
return 0 ;
it fails with 'undefinied Reference' erros at each wiringPi commands.

(While the Anjuta's default "Hello World!" work well.)

Of course I tried to set a lot of combination the gcc options what mentioned in this forum thread and other places under the Anjuta's Project/Properties windows textboxes:
  • -I/usr/include
  • -lwiringPi
  • -L/usr/lib (and) -L/usr/lib/aarch64-linux-gnu (This is where the system find the libwiringPi.so link)
I edited the /etc/ld.so.conf.d and added the
  • include /usr/lib

and run sudo ldconf too

but it doesn't work at all...

If I use gcc directly from terminal everything is fine:

$ gcc ...path/main.c -lwiringPi -o blinkled

gcc do it's work and compile well. The program do what it need to do... (blink the led which connected to GPIO)

(As I mentioned above the gpio work well too.)

So I can't find the solution what very annoying to me because I use Anjuta on my desktop PC and I like it...
Like enough it's not the wiringPi's fault but Anjuta's but I didn't find better thread

Please help me if someone can!


Posts: 2
Joined: Sun Jun 16, 2019 2:55 pm
Location: Hungary

Re: wiringPi undefined Reference

Sun Jun 16, 2019 11:50 pm


I don't konw how to answer to my own post...
But accidentally I found and solved the problem yet.

I write here how, because maybe will help someone else.

So the reason why nothing worked with wiringPi in Ajuta is that when start to create a new project must
check in the "Add shared library support" checkbox/button.
If I missed it nothing worked to me.
But If check this in then enough to add 'LDFLAGS=-lwiringPi' to the Build->Configure project... panel "Configure Options" texbox

It sure this not wiringPi problem but maybe help...

Have a nicer day then my was! :)


Return to “C/C++”