我正在尝试使用 CMake 在 Mac 上的 CLion 中使用 CPPREST SDK。我快到了,但我似乎无法解决以下链接器错误:
Undefined symbols for architecture x86_64:
"_ERR_remove_thread_state", referenced from:
boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in PongRemote.cpp.o
我指定了 -lssl 和 -lcrypto,但仍然得到这个“线程状态”错误。根据一些研究,它看起来像是来自 OpenSSL。我使用 Homebrew 安装 CPPREST。
我已经测试了这个,实际上只是一个主要的,基本的包括:
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
使用以下 CMake:
project(cpprest)
cmake_minimum_required(VERSION 3.8)
set(CMAKE_CXX_STANDARD 14)
# BOOST PACKAGE
find_package(Boost REQUIRED COMPONENTS
atomic
chrono
date_time
exception
filesystem
random
regex
serialization
system
thread
)
include_directories(${Boost_INCLUDE_DIRS})
IF (!Boost_FOUND)
MESSAGE("*** ERROR *** Boost package not found")
RETURN()
ENDIF ()
# Microsoft RESTful API Package (Casablanca)
set(CPPREST_LIBRARIES "/usr/local/opt/openssl/lib")
include_directories("/usr/local/opt/openssl/include")
# Compile and link
# Build the core library and executable
include_directories(${CMAKE_SOURCE_DIR})
set(SOURCE_FILES
main.cpp
)
set(LINK_LIBRARIES
${Boost_LIBRARIES}
${CPPREST_LIBRARIES}
-lssl
-lcrypto
)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARIES})