3

I try to link a shared library just installed on my system, but for some reason the output doesn't want to execute. This is my compilation:

gcc -o test test.c -lgpio

When running the output, I get the following error:

./test: error while loading shared libraries: libgpio-3.0.0.so.3: cannot open shared object file: No such file or directory

Which is weird since I have this exact file in my /usr/local/lib-folder (along with libgpio-3.0.0.so and the other shared library files). I don't have much experience with GCC, so can someone please explain what went wrong?

Totemi1324
  • 468
  • 1
  • 6
  • 19

1 Answers1

2

Your library folder is probably not in the default search path. You'll need to specify it using the -L option when you compile:

gcc -L /usr/local/lib-folder -o test test.c -lgpio

You'll also need to add this folder to the LD_LIBRARY_PATH environment variable when you run the program.

dbush
  • 205,898
  • 23
  • 218
  • 273