我正在开发一个需要一个侦听http请求的小型服务器的小软件。遗憾的是,高效服务器仅使用https,因此请求失败。我在网上搜索并找到了这个例子:http://www.boost.org/doc/libs/1_65_0/doc/html/boost_asio/example/cpp03/ssl/server.cpp
我尽力应用所需的更改。但我无法编译它。我在MacOS机器上,但服务器是Ubuntu服务器。我通过brew安装了OpenSSL。
编译在链接过程中失败:
[ 98%] Linking CXX executable GpdServer
Undefined symbols for architecture x86_64:
"_ERR_remove_thread_state", referenced from:
boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in main.cpp.o
boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in TcpServer.cpp.o
boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in TcpConnection.cpp.o
"_TLSv1_1_client_method", referenced from:
boost::asio::ssl::context::context(boost::asio::ssl::context_base::method) in TcpServer.cpp.o
"_TLSv1_1_method", referenced from:
boost::asio::ssl::context::context(boost::asio::ssl::context_base::method) in TcpServer.cpp.o
"_TLSv1_1_server_method", referenced from:
boost::asio::ssl::context::context(boost::asio::ssl::context_base::method) in TcpServer.cpp.o
"_TLSv1_2_client_method", referenced from:
boost::asio::ssl::context::context(boost::asio::ssl::context_base::method) in TcpServer.cpp.o
"_TLSv1_2_method", referenced from:
boost::asio::ssl::context::context(boost::asio::ssl::context_base::method) in TcpServer.cpp.o
"_TLSv1_2_server_method", referenced from:
boost::asio::ssl::context::context(boost::asio::ssl::context_base::method) in TcpServer.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [GpdServer] Error 1
make[1]: *** [CMakeFiles/GpdServer.dir/all] Error 2
make: *** [all] Error 2
导致此问题的TcpConnection文件位于: https://github.com/cwansart/gpd/blob/master/src/TcpServer.h https://github.com/cwansart/gpd/blob/master/src/TcpServer.cpp
我的构建系统是CMake。包括它工作正常。
我做错了什么?我该如何解决这个问题?
答案 0 :(得分:0)
事实证明,macOS是个问题。我通过brew安装了OpenSSL。首先,我的CLion / CMake没有找到它,所以我添加了一个if来检查它是否是Apple PC。在那种情况下,我手动将路径设置为brew给我的路径。现在,由于某种原因,链接不起作用。
在使用libssl-dev的Linux上没有问题。