building shared libraries
the code for the library is mylib.c
the code for the main program is prog.c
gcc -fPIC -g -c -Wall mylib.c creates mylib.o
gcc -shared -Wl,-R,`pwd`,-soname,mylib.so -o libmylib.so.0 mylib.o -lc
mv libmylib.so.0 ./lib/.
now link them into the final binary:
gcc prog.c -o myprog -L./lib -lmylib -lc
but this does not work.
ldd shows mylib.so is not found even when LD_LIBRARY_PATH is set to the directory where it is located.
the code for the main program is prog.c
gcc -fPIC -g -c -Wall mylib.c creates mylib.o
gcc -shared -Wl,-R,`pwd`,-soname,mylib.so -o libmylib.so.0 mylib.o -lc
mv libmylib.so.0 ./lib/.
now link them into the final binary:
gcc prog.c -o myprog -L./lib -lmylib -lc
but this does not work.
ldd shows mylib.so is not found even when LD_LIBRARY_PATH is set to the directory where it is located.

0 Comments:
Post a Comment
<< Home