mediapipe中使用了大量的ProtoBuf技术来表示图结构,而且mediapipe原生并不是采用cmake来构建项目,而是使用google自家研发的bazel,这个项目构建系统我就不评价了,而现在我需要使用Cmake来对其进行构建。 这也是噩梦的开始,mediapipe的.proto文件很多,核心的framework的目录下存在很多的.proto文件,根目录和子目录都有.proto文...
手动安装protobuf情况下,在编译路径中可以找到cmake文件夹,其中包含了关键文件protobuf-config.cmake和protobuf-config.cmake(可能带有 .in 后缀) 设置该路径为<package>_DIR,实现如下: # /root/cyh/protobuf/build/protobuf-3.20.1 为我编译的路径 set(protobuf_DIR "/root/cyh/protobuf/build/protobuf-3.20...
一般来说,protobuf经常搭配Cmake使用,Cmake有官方的modules,可以通过简单的几个命令protobuf_generate_cpp来生成对应的.pb.cc和.pb.h。 简单的例子: find_package(Protobuf REQUIRED) include_directories(${Protobuf_INCLUDE_DIRS}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) protobuf_generate_cpp(PROTO...
当确认Protobuf_DIR设定到了正确路径,例如~/soft/protobuf-3.8.0/lib/cmake/protobuf,清理CMakeCache.txt,再执行cmake,发现找到了protobuf但是版本不对:找到了2.6.1版本的也就是apt安装的版本,而不是自行编译安装的3.8.0版本: set(Protobuf_DIR "/home/zz/soft/protobuf-3.8.0/lib/cmake/protobuf") fin...
target_link_libraries(bar ${Protobuf_LIBRARIES}) 但是这个例子太简单了,如果我们的.proto文件只有一个或者说都只在一个目录里,那用这个命令没什么毛病... 但如果是这种情况,我们的文件目录如下: ├── CMakeLists.txt ├── README.md ├── meta ...
protobuf protobuf 是谷歌发布的一种数据封装协议, 用于数据传输。在使用时需要定义好 proto 文件, 然后用 protoc 工具编译为 pb.h 和pb.cc文件。打开命令行输入如下命令 protoc -I=${proto_file_dir} --cpp_out=${pb_file_dir} *.proto 这里面有三个参数, -I 表示 proto 文件的路径; --cpp_out 表...
protobuf 是谷歌发布的一种数据封装协议, 用于数据传输。在使用时需要定义好 proto 文件, 然后用 protoc 工具编译为 pb.h 和 pb.cc 文件。打开命令行输入如下命令 protoc -I=${proto_file_dir} --cpp_out=${pb_file_dir} *.proto 这里面有三个参数, -I 表示 proto 文件的路径; --cpp_out 表示输出...
#message(STATUS "ProtoFiles: ${PROTOBUF_TARGET_CPP_UNPARSED_ARGUMENTS}") #message(STATUS "install folder: ${PROTOBUF_TARGET_CPP_INSTALL_FOLDER}") PROTOBUF_GENERATE_CPP_EXT(proto_sources proto_headers proto_include_dirs ${PROTO_ROOT} ${PROTOBUF_TARGET_CPP_UNPARSED_ARGUMENTS}) PROTOBUF_TARGET_...
CMake Error at CMakeLists.txt:9 (find_package): Could not find a package configuration file provided by "protobuf" with any of the following names: protobufConfig.cmake protobuf-config.cmake Add the installation prefix of "protobuf" to CMAKE_PREFIX_PATH or set "protobuf_DIR" to a di...
这个例子展示了如何使用Protobuf生成源文件。Protocol Buffers是Google提供的一种数据序列化格式。用户提供带有数据描述的.proto文件。然后使用Protobuf编译器,可以将该原始文件翻译成包括C++在内的多种语言的源代码。 本教程中的文件如下: $ tree . ├── AddressBook.proto ...