1. undefined reference to symbol ‘pthread_key_delete@@GLIBC_2.2.5
未定义对某符号的引用,该错误为链接时(linking)发生的错误。有如下方式的解决方案:
- 修改 Makefile 文件,为变量
LDFLAGS
加入,-L /lib64 -l pthread
;- 通过
TARGET_LINK_LIBRARIES(... -lpthread -lm)
将-lpthread -lm
添加进CMakelists.txt
文件;
- 通过
2. 通过 cmake 的方式链接 google protobuf
How to link google protobuf libraries via cmake on linux?
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
...
target_link_libraries(complex
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${PROTOBUF_LIBRARY}
)