所以,我正在尝试利用thrift,并决定生成一个C ++服务器。我正在使用CLion,clang和CMake来编译项目。但是,当我尝试编译生成的thrift服务器时,它会抱怨链接阶段缺少符号..
链接错误与我使用nm
找到的这些符号有关:
0000000000000160 T __ZN6apache6thrift5async25TConcurrentClientSyncInfo10getPendingERNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERNS0_8protocol12TMessageTypeERi
0000000000000250 T __ZN6apache6thrift5async25TConcurrentClientSyncInfo13updatePendingERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENS0_8protocol12TMessageTypeEi
我的主要问题是我不知道如何继续。符号似乎在那里,导致错误的代码由thrift工具生成,而不是我。
以下是相关信息:
OS X 10.11.4
CMake 3.3
Apple LLVM version 7.3.0 (clang-703.0.29)
的CMakeLists.txt:
cmake_minimum_required(VERSION 3.3)
project(KodLogicDaemon)
include_directories(
/usr/local/include
../Vendor/kod-logic
)
link_directories(
/usr/local/Cellar/thrift/0.9.3/lib
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
set(SOURCE_FILES
main.cpp
Thrift/DKLogic.cpp
Thrift/interface_types.cpp
)
add_executable(KodLogicDaemon ${SOURCE_FILES})
target_link_libraries(KodLogicDaemon thrift KodLogic)
错误:
Undefined symbols for architecture x86_64:
"apache::thrift::async::TConcurrentClientSyncInfo::getPending(std::string&, apache::thrift::protocol::TMessageType&, int&)", referenced from:
DKLogicConcurrentClient::recv_calculateBestMove(TMove&, int) in DKLogic.cpp.o
DKLogicConcurrentClient::recv_validateMove(int) in DKLogic.cpp.o
"apache::thrift::async::TConcurrentClientSyncInfo::updatePending(std::string const&, apache::thrift::protocol::TMessageType, int)", referenced from:
DKLogicConcurrentClient::recv_calculateBestMove(TMove&, int) in DKLogic.cpp.o
DKLogicConcurrentClient::recv_validateMove(int) in DKLogic.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]: *** [KodLogicDaemon/KodLogicDaemon] Error 1
make[1]: *** [KodLogicDaemon/CMakeFiles/KodLogicDaemon.dir/all] Error 2
make: *** [all] Error 2