当在win10系统利用cmake进行工程编译时出现以下报错时,可以采取以下办法:
通过手动build和install Protobuf 的方法进行解决,具体步骤如下:
步骤一:下载源码zip包,并解压到某路径,比如 C:\Protobuf,同时创捷build路径C:\Protobufbuild;
步骤二:cmake -G Ninja -S C:\Protobuf -B C:\Protobufbuild -DCMAKE_INSTALL_PREFIX=C:\protobuf-21.12
若未安装Ninja,则下载安装
步骤三:cd to C:\Protobufbuild然后执行命令 ninja install
download Protobuf source code, extract to a directory such as C:\Protobuf, create a build directory such as C:\Protobufbuild
步骤四:cd到项目源码路径下然后执行命令cmake . -B build -DProtobuf_LIBRARIES=C:\protobuf-21.12\lib -DProtobuf_INCLUDE_DIR=C:\protobuf-21.12\include
注意:不要下载安装预编译的Protobuf binaries,比如protoc-21.12-win64.zip,因为在预编译中丢失了一些包。