Link to a specific library with C

I need to use SNAP C-library.

I compiled snap_test.c with the following command:

gcc -fopenmp -c -I/home/myName/SNAPDIR/include snap_test.c 

And then linked it to the library:

 gcc -fopenmp -o snap_test -L/home/myName/SNAPDIR/lib -lsnap snap_test.o 

But starting the program leads to an error:

 ./snap_test: error while loading shared libraries: libsnap.so.0: cannot open shared object file: No such file or directory 

There are those files and files in lib-dir:

 libsnap.a libsnap.la libsnap.so (dir) libsnap.so.0 (dir) libsnap.so.0.0.0 

I assume the problem is in different versions of the libraries ?!

+4
source share
1 answer

You need to add /home/myName/SNAPDIR/lib to LD_LIBRARY_PATH .

 $ export LD_LIBRARY_PATH+=:/home/myName/SNAPDIR/lib 
+2
source

Source: https://habr.com/ru/post/1390730/


All Articles