未定义对符号X509_free的引用 [英] Undefined reference to symbol X509_free
问题描述
我正在尝试使用mongodb旧版C ++驱动程序. (这里的旧版"是指生产版本,fwiw.)在使用clang ++ 3.6和boost 1.55(来自ubuntu软件包存储库)的ubuntu 15.04主机上,并使用git形式的mongo-cxx-driver驱动程序,我编译了驱动程序,然后尝试编译测试程序.
I'm trying to use the mongodb legacy C++ driver. (Here "legacy" means the production version, fwiw.) On an ubuntu 15.04 host using clang++ 3.6 and boost 1.55 (from the ubuntu package repositories) and using mongo-cxx-driver pulled form git, I compiled the driver and then attempted to compile the test program.
$ 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中(它是openSSL1.0.0,dpkg和库符号链接本身说的).
Clearly I'm missing X509_free()
, but it appears that should be in libssl (which is openSSL1.0.0, says dpkg and the library symlink itself).
非常感谢您提供任何提示.
Many thanks for any tips.
我认为这里并不重要,但这是mongo.cc:
I don't think it's important here, but this is 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
,而不是libcrypt.so
.
这篇关于未定义对符号X509_free的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!