VS2019 配置 protobuf3.8.0


1、下载protobuf3.8.0

https://github.com/protocolbuffers/protobuf/releases/tag/v3.8.0

2、准备工作

解压文件并在同级目录建立install文件夹,用作编译完成后方include ,lib等文件

3、编译工作

使用VS开发人员命令行工具进入protobuf目录,创建build目录

D:\3rdParty\protobuf-cpp-3.8.0\protobuf-3.8.0\cmake>mkdir build & cd build
D:\3rdParty\protobuf-cpp-3.8.0\protobuf-3.8.0\cmake\build>

创建debug版本的编译目录:

D:\3rdParty\protobuf-cpp-3.8.0\protobuf-3.8.0\cmake\build>mkdir debug & cd debug
D:\3rdParty\protobuf-cpp-3.8.0\protobuf-3.8.0\cmake\build\debug>cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../../../install ../..

3.1、创建生成的visual studio工程文件夹

D:\3rdParty\protobuf-cpp-3.8.0\protobuf-3.8.0\cmake\build>mkdir solution & cd solution 
D:\3rdParty\protobuf-cpp-3.8.0\protobuf-3.8.0\cmake\build\solution>cmake -G "Visual Studio 16 2019" -DCMAKE_INSTALL_PREFIX=../../../../install ../..

注:因为安装了visual studio 2019而决定的,这是所谓的generator,不同编译器是不同的,具体类型可见: http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators

通过上述步骤后,可以在响应的目录中都生成了Makefile文件,接下来就是执行nmake进行编译

D:\3rdParty\protobuf-cpp-3.8.0\protobuf-3.8.0\cmake\build\debug>nmake

安装头文件、库文件等到指定的文件夹(install): ``` D:\3rdParty\protobuf-cpp-3.8.0\protobuf-3.8.0\cmake\build\debug>nmake install ```

至此debug版本都编译成功,release版本同样的操作即可。
然后将install目录下的include、lib文件包含到工程中即可


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM