无法使用谷歌的protobuf构建测试C++应用程序
Can't build test C++ app with Google's protobuf
我正在尝试用CMake构建示例c++ protobuf应用程序。但是链接器找不到一些与protobuf相关的方法。
我使用开发人员指南中的示例。proto文件。但是当链接器试图为protobuf生成的c++代码构建对象文件时,我有很多这样的错误:
undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)'
undefined reference to `google::protobuf::internal::empty_string_'
undefined reference to `google::protobuf::internal::InitEmptyString()'
undefined reference to `google::protobuf::internal::empty_string_once_init_'
undefined reference to `google::protobuf::internal::WireFormat::VerifyUTF8StringFallback(char const*, int, google::protobuf::internal::WireFormat::Operation, char const*)'
我使用的是自己用GCC 4.8.4构建的protobuf 2.6.1。示例应用程序是由CMake在QTCreator中使用QT 5.5.1工具集和GCC 4.8.4构建的。这是我的cmakelist。txt
project(protobuf-test)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
LINK_DIRECTORIES(/usr/lib)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} pthread protobuf)
谢谢你的帮助!
链接器搜索路径中出现问题。链接器试图使用来自OS发行版(版本8.0.0)的libprotobuf,而不是我自己构建的lib(版本9.0.1)。
相关文章:
- 以现代 CMake 方式控制包含的库中的构建选项(测试等)
- 如何在提升构建中设置环境变量以进行提升单元测试框架?
- 无法构建 RcppArmadillo.package.skeleton 测试包:"R_init_"的多重定义<name>
- 使用cmake构建google测试单元测试时出现链接器错误
- 为多个测试文件构建可执行文件
- 在 Linux 上构建 cpptest 单元测试框架
- 使用 QtCreator 构建 CUDA/C++ 测试程序时出现错误 2
- 我想使用 CMake 生成和编译 Visual Studio projet,我需要从构建中排除单元测试文件。有没有办法做到这一点?
- C++ CppUnitTestFramework 在构建后运行测试
- 如何在 Android Studio 中构建本地/主机操作系统C++单元测试?
- 测试构建C++包装器时出现 OpenCV 错误
- 实施 SystemC TLM 测试平台构建失败
- GTEST/Google测试C 在Visual Studio 2017上构建错误
- CEF-使用MDd构建测试
- dlib示例,测试构建失败
- 构建和链接 Crypto++ 的测试代码
- Qt 5测试版2,Qt Creator 2.6,MSVC错误:Qt Creaator需要一个编译器来构建.在工具包选项中
- 使用Google测试,CLANG和LIBC 进行故障构建测试
- CMAKE中的预期构建测试
- 无法使用谷歌的protobuf构建测试C++应用程序