我正在尝试使用 mongodb 旧版 C++ 驱动程序。 (这里的“legacy”是指生产版本,fwiw。)在使用 clang++ 3.6 和 boost 1.55(来自 ubuntu 软件包存储库)并使用 mongo-cxx-driver 从 git 中拉取的 ubuntu 15.04 主机上,我编译了驱动程序,然后尝试编译测试程序。
$ clang++ -std=c++14 mongo.cc -pthread -lmongoclient -lboost_thread \
-lboost_system -lboost_regex -lssl -o mo
我看到这个错误:
clang++ -std=c++14 mongo.cc -pthread -lmongoclient -lboost_thread -lboost_system -lboost_regex -lssl -lcrypt -o mo
/usr/bin/ld: /usr/local/lib/libmongoclient.a(ssl_manager.o): undefined reference to symbol 'X509_free@@OPENSSL_1.0.0'
/lib/x86_64-linux-gnu/libcrypto.so.1.0.0: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)
显然我失踪了X509_free()
,但看起来应该在 libssl 中(dpkg 和库符号链接本身说是 openSSL1.0.0)。
非常感谢您的任何提示。
我认为这在这里并不重要,但这是 mongo.cc:
#include <cstdlib>
#include <iostream>
#include "mongo/client/dbclient.h" // for the driver
void run() {
mongo::DBClientConnection c;
c.connect("localhost");
}
int main() {
mongo::client::initialize();
try {
run();
std::cout << "connected ok" << std::endl;
} catch( const mongo::DBException &e ) {
std::cout << "caught " << e.what() << std::endl;
}
return EXIT_SUCCESS;
}
你应该链接到libcrypto.so
, not libcrypt.so
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)