当我在 cpp 中构建我的 cpp 项目时...这是输出。
**** Build of configuration Debug for project rtbCookieServer ****
make all
Building file: ../src/rtbCookieServer.cpp
Invoking: GCC C++ Compiler
g++ -I/home/cpp/mongo-cxx-driver-v2.0/mongo -I/home/cpp/mongo-cxx-driver-v2.0 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/rtbCookieServer.d" -MT"src/rtbCookieServer.d" -o"src/rtbCookieServer.o" "../src/rtbCookieServer.cpp"
Finished building: ../src/rtbCookieServer.cpp
Building target: rtbCookieServer
Invoking: GCC C++ Linker
g++ -L/home/cpp/mongo-cxx-driver-v2.0 -lfcgi++ -lboost_system -lcgicc -lmongoclient -o"rtbCookieServer" ./src/rtbCookieServer.o
Finished building target: rtbCookieServer
W=当我运行代码时...这是我收到的错误消息。
/home/workspace/rtbCookieServer/Debug/rtbCookieServer: error while loading shared libraries: libmongoclient.so: cannot open shared object file: No such file or directory
文件在 home/cpp/mongo-cxx-driver-v2.0 为什么找不到呢????
谢谢
最佳答案
比使用 LD_LIBRARY_PATH 更好的是指定运行库搜索
-Wl,-rpath /home/cpp/mongo-cxx-driver-v2.0
有关为什么不使用 LD_LIBRARY_PATH 的更多信息,请查看例如here .
关于c++ - mongoDB,C++ libmongoclient.so : cannot open shared object file: No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8968845/