简体   繁体   中英

Linking to a Specific Library with C

I have to use the SNAP C-library.

I compiled my file snap_test.c with the following command:

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

And then linked it with the library:

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

But running 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

In the lib-dir there are those dirs and files:

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

I guess the problem is the different versions of the libraries?!

您需要将/home/myName/SNAPDIR/libLD_LIBRARY_PATH

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM