./test:加载共享库时出错:libcpprest.so.2.8:无法打开共享对象文件:没有这样的文件或目录

./test: error while loading shared libraries: libcpprest.so.2.8: cannot open shared object file: No such file or directory

我正在执行以下编译命令行:

g++ -std=c++11 -I/home/admin/Github/casablanca/Release/include -L/home/admin/Github/casablanca/Release/build.debug/Binaries test.cc -o test -lboost_system -lcrypto -lssl -lcpprest

编译成功,但在运行时出现此错误:

./test: error while loading shared libraries: libcpprest.so.2.8: cannot open shared object file: No such file or directory

尽管文件 libcpprest.so.2.8 存在于指定位置:

admin:$ ls /home/admin/Github/casablanca/Release/build.debug/Binaries/libcpprest.so*
/home/admin/Github/casablanca/Release/build.debug/Binaries/libcpprest.so
/home/admin/Github/casablanca/Release/build.debug/Binaries/libcpprest.so.2.8

如有任何建议,我将不胜感激

谢谢

我猜运行时错误是因为 /home/admin/Github/casablanca/Release/build.debug/Binaries/ 路径没有包含在 LD_LIBRARY_PATH 环境变量中。如果您在 shell 中执行 "echo $LD_LIBRARY_PATH",您应该确认 运行。