可执行错误
Closed this issue · 1 comments
通过cmake .. &&make 产生的可执行运行没有问题, 通过make install安装到${CMAKE_INSTALL_PREFIX}/bin的可执行运行错误,显示没有找到libhello_shared.so 查看文件目录,libhello_shared.so已经被成功安装到${CMAKE_INSTALL_PREFIX}/lib中
chengyuqi@chengyuqi:~/learn/summercamp/SummerCamp2018Homework/tool/cmake/程宇�
��/src/build$ ./hello_demo
Compiled success!
SharedLibDemo: My name is SharedLibDemo
StaticLibDemo: My name is StaticLibDemo
chengyuqi@chengyuqi:~/learn/summercamp/SummerCamp2018Homework/tool/cmake/程宇�
��$ ./src/bin/hello_demo
./src/bin/hello_demo: error while loading shared libraries: libhello_shared.so: cannot open shared object file: No such file or directory
This problem is because the binary relies on the shared library and the library can't be found by it. You can try to add the location of ${CMAKE_INSTALL_PREFIX}/lib to LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${CMAKE_INSTALL_PREFIX}/lib