Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

DolphinDB C++ API 编译报错 对‘SSL_CTX_free’未定义的引用

我根据教程在linux操作系统上使用DolphinDB C++ API。编译main.cpp的时候遇到这个问题:

g++ main.cpp -std=c++11 -DLINUX -D_GLIBCXX_USE_CXX11_ABI=1 -DLOGGING_LEVEL_2 -O2 -I../include   -lDolphinDBAPI -lpthread -L../bin/linux_x64/ABI1  -Wl,-rpath,.:../bin/linux_x64/ABI1 -o main
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_CTX_free’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_get_error’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘X509_NAME_oneline’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_get_peer_certificate’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘X509_get_subject_name’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘X509_free’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_library_init’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_read’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_shutdown’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘X509_get_issuer_name’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘OPENSSL_add_all_algorithms_noconf’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_CTX_new’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘uuid_generate’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘TLSv1_2_client_method’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_connect’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_load_error_strings’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_free’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_write’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_set_fd’未定义的引用
../bin/linux_x64/ABI1/libDolphinDBAPI.so:对‘SSL_new’未定义的引用
collect2: error: ld returned 1 exit status

之前我已经安装了openssl和相关依赖库,G++版本为7.5,各位大神情况这是什么情况造成的呢?谢谢!
后面我有使用了教程中的

g++ main.cpp -std=c++11 -DLINUX -D_GLIBCXX_USE_CXX11_ABI=0 -DLOGGING_LEVEL_2 -O2 -I../include   -lDolphinDBAPI -lpthread -L../bin/linux_x64/ABI0  -Wl,-rpath,.:../bin/linux_x64/ABI0 -o main

依然报的一样的错误,C++API是今天刚从GitHub下载下来的


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

这个错误是因为没链接SSL库,请在编译命令中加上-lssl,例如:

g++ main.cpp -std=c++11 -DLINUX -D_GLIBCXX_USE_CXX11_ABI=1 -DLOGGING_LEVEL_2 -O2 -I../include   -lDolphinDBAPI -lssl -lpthread  -L../bin/linux_x64/ABI1  -Wl,-rpath,.:../bin/linux_x64/ABI1 -o main

注意有些电脑上可能需要通过 -lDolphinDBAPI /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 这种方式链接SSL。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...