I'm trying to compile a simple program on my Ubuntu using the ARM cross compile toolchain (arm-linux-gnueabihf-gcc) and run it on my Raspberry Pi. The program is using the wiringPi shared library (wiringPi.so) located in ~/wiringPi/wiringPi on Ubuntu. The code follows:

#include "wiringPi.h"

int main (void)
    pinMode(0, OUTPUT);

    for (;;)
        digitalWrite(0, HIGH);
        digitalWrite(0, LOW);

    return 0;

I used the command:

arm-linux-gnueabihf-gcc blinking.c -o blinking -L ~/wiringPi/wiringPi -lwiringPi -I ~/wiringPi/wiringPi

to compile and successfully get the object file, which I then transfer to Raspberry Pi.
However, when trying to run the program on Pi, I get the following error:
./blinking: error while loading shared libraries: libwiringPi.so: cannot open shared object file: No such file or directory

What am I missing?

  • It looks like it can't find the library on the Pi. Have you installed wiringPi on the Pi (it should be preinstalled in full Raspbian, but not in Raspbian Lite).
    – joan
    Commented Apr 5, 2019 at 20:35
  • @joan Haven't installed wiringPi on Raspberry (using Raspbian Lite). I thought the compiler links the shared libraries to the program object files. I guess I need to learn more about dynamic libraries. Just saw the answer by Ralf which explains it.
    – A6SE
    Commented Apr 5, 2019 at 20:41
  • 1
    The Answer and comment are true BUT the the library should be installed on standard Raspbian - it is used by gpio. Currently /usr/lib/libwiringPi.so.2.50 (with a link from /usr/lib/libwiringPi.so) I note the OP has not identified what OS is in use.
    – Milliways
    Commented Apr 5, 2019 at 22:28

1 Answer 1


Shared or dynamic libraries are needed at run time. So you need the library not only on the build system but in on the target system, in this case on the PI.

This is different from static libraries. If you use a static library at build time, all the needed code from the library would be included in the executable, and the library would not be needed to run the program.

So you have to copy the library to the PI into a directory that is searched for shared libraries, such as /usr/lib or /usr/local/lib. You can also set LD_LIBRARY_PATH to point to the library, but then you must make sure it is always set when you want to execute the program.

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.