0

I am trying to run an example program from the wiringPi in C++ in Geany software(called blink.cpp)

This is the code (I did not do it, I took it directly from the wiringPi exmples in order to see how the GPIO from Raspberry Pi works):

#include <stdio.h>
#include <wiringPi.h>

// LED Pin - wiringPi pin 0 is BCM_GPIO 17.

#define LED 0

int main(void) {
    printf("Raspberry Pi blink\n");

    wiringPiSetup();
    pinMode(LED, OUTPUT);

    for (;;) {
        digitalWrite(LED, HIGH);  // On
        delay(500);               // mS
        digitalWrite(LED, LOW);   // Off
        delay(500);
    }
    return 0;
}

However, I recieve this message: Error messages

I know that I have to add some path somewhere in order to link the wiringPi with Geany using -lwiringPi but I dont know how. If someone can help me and explain me I would really appreciate it.

Thanks in advance

paolo
  • 2,345
  • 1
  • 3
  • 17
emmanuel
  • 5
  • 4

1 Answers1

0

You are getting linker errors. This means linter can't find library. Link against wiringPI http://wiringpi.com/reference/

Šeky
  • 26
  • 3
  • Hi, Thanks for your answer: the link says that I have to add this: -I/usr/local/include -L/usr/local/lib -lwiringPi – emmanuel May 14 '22 at 10:57
  • but where? directly to the program or another file? – emmanuel May 14 '22 at 10:57
  • how do you start compilation? from the program somewhere or from the command line interface? if you start it from the CLI just add it to gcc command. if you start it using Build button in your software, go to Properties->Build and add it under Link https://wiki.geany.org/howtos/configurebuildmenu – Šeky May 14 '22 at 11:02
  • Thank you so much I was doing it wrong but you gave me a very good hint!!! I am using a software, so I solved it like this. – emmanuel May 15 '22 at 10:35
  • 1
    1. Build ->Set Build Commands 2. In the C commands under the label Build and in the Command column I wrote the follow: gcc -Wall "%f" -lwiringPi -o "%e". 3. EVERTHING WAS WORKING!! Thanks for your help and have a nice weekend (the important heres is the -lwiringPi) – emmanuel May 15 '22 at 10:38