1
我正在编写一个简单的hello世界程序,以了解如何在Linux中链接共享库。我已成功使用的主要程序编译成与共享库的可执行如下:在linux中使用共享库执行二进制文件
g++ -fPIC -c lab2_hello_main.cpp <--create position independent objects
g++ -fPIC -c lab2_hello_sub.cpp
g++ -fPIC -shared -Wl,-soname=libfuncs.so.1.0 *.o -o libfuncs.so.1.0 -lc <--make the shared library
ln -s libfuncs.so.1.0 libfuncs.so <-- soft links for compiling and running
ln -s libfuncs.so.1.0 libfuncs.so.1
g++ -o hello_dyn lab2_hello_main.cpp -L/mypath -lfuncs <-- Linking the library to main
当我hello_dyn做一个LDD我得到的输出,指出该库无法找到:
"libfuncs.so.1.0 => not found"
它自动查找的其他库自动罚款。
任何人都知道这可能是为什么?
google LD_LIBRARY_PATH – nogard
正是我需要知道的。谢谢 –