protobuf3.4在VS2015环境下编译
2017-08-20 11:38
405 查看
1、首先必须保证已下载安装VS2015、Git、CMake。
2、从Github中下载protobuf的压缩包,然后选择一个目录进行解压。
3、然后在解压目录的同级目录新建文件夹install(用于存放头文件/库/二进制文件)。
4、在(解压目录)\cmake目录下创建build目录,进入build目录,创建release、debug、solution三个目录。
5、打开开始面板,点击VS2015文件夹,点击“VS2015 x62 x86兼容工具命令提示符”。
6、编译时要安装gmock,google的单元测试工具,否则后期编译时会报错。cd进入到(解压目录),先创建一个gmock文件夹,然后执行指令git clone -b release-1.7.0 https://github.com/google/googlemock.git gmock
cd进入gmock目录,执行指令git clone -b release-1.7.0 https://github.com/google/googletest.git gtest
老版本的gmock与gtest是分开的,新版本做到了一起。
7、假设我们的解压目录是 C:\Path\to\protobuf,执行下列指令
C:\Path\to\protobuf\gmock>cd ..\cmake\build\release
C:\Path\to\protobuf\cmake\build\release>cmake -G “NMake Makefiles” ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
同样的,进入debug目录执行指令
C:\Path\to\protobuf\cmake\build\debug>cmake -G “NMake Makefiles” ^
-DCMAKE_BUILD_TYPE=Debug ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
进入solution目录执行
C:\Path\to\protobuf\cmake\build\solution>cmake -G “Visual Studio 12 2013 Win64” ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
根据你的需要去执行其中一个,当然都执行也可以
前两个是创建makefile文件,后者是生成VS解决方案。
8、编译
C:\Path\to\protobuf\cmake\build\release>nmake
或者
C:\Path\to\protobuf\cmake\build\debug>nmake
也可以通过VS打开项目解决方案,选择debug或release,在生成菜单中选择”Build Solution”.
9、测试
C:\Path\to\protobuf\cmake\build\release>nmake check
或
C:\Path\to\protobuf\cmake\build\debug>nmake check
也可以通过VS
10、安装
C:\Path\to\protobuf\cmake\build\release>nmake install
或
C:\Path\to\protobuf\cmake\build\debug>nmake install
成功!!!
11、如果你想在libprotobuf中包含GzipInputStream与GzipOutputStream
(google/protobuf/io/gzip_stream.h),
Make sure zlib’s two headers are in your
Make sure zlib’s linking libraries (*.lib file) is in your
下载
C:\Path\to>git clone -b v1.2.8 https://github.com/madler/zlib.git
C:\Path\to>cd zlib
编译与安装
C:\Path\to\zlib>mkdir build & cd build
C:\Path\to\zlib\build>mkdir release & cd release
C:\Path\to\zlib\build\release>cmake -G “NMake Makefiles” -DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX=../../../install ../..
C:\Path\to\zlib\build\release>nmake & nmake install
当然也可以是debug
12、Now add bin folder from install to system PATH:
C:\Path\to>set PATH=%PATH%;C:\Path\to\install\bin
2、从Github中下载protobuf的压缩包,然后选择一个目录进行解压。
3、然后在解压目录的同级目录新建文件夹install(用于存放头文件/库/二进制文件)。
4、在(解压目录)\cmake目录下创建build目录,进入build目录,创建release、debug、solution三个目录。
5、打开开始面板,点击VS2015文件夹,点击“VS2015 x62 x86兼容工具命令提示符”。
6、编译时要安装gmock,google的单元测试工具,否则后期编译时会报错。cd进入到(解压目录),先创建一个gmock文件夹,然后执行指令git clone -b release-1.7.0 https://github.com/google/googlemock.git gmock
cd进入gmock目录,执行指令git clone -b release-1.7.0 https://github.com/google/googletest.git gtest
老版本的gmock与gtest是分开的,新版本做到了一起。
7、假设我们的解压目录是 C:\Path\to\protobuf,执行下列指令
C:\Path\to\protobuf\gmock>cd ..\cmake\build\release
C:\Path\to\protobuf\cmake\build\release>cmake -G “NMake Makefiles” ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
同样的,进入debug目录执行指令
C:\Path\to\protobuf\cmake\build\debug>cmake -G “NMake Makefiles” ^
-DCMAKE_BUILD_TYPE=Debug ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
进入solution目录执行
C:\Path\to\protobuf\cmake\build\solution>cmake -G “Visual Studio 12 2013 Win64” ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
根据你的需要去执行其中一个,当然都执行也可以
前两个是创建makefile文件,后者是生成VS解决方案。
8、编译
C:\Path\to\protobuf\cmake\build\release>nmake
或者
C:\Path\to\protobuf\cmake\build\debug>nmake
也可以通过VS打开项目解决方案,选择debug或release,在生成菜单中选择”Build Solution”.
9、测试
C:\Path\to\protobuf\cmake\build\release>nmake check
或
C:\Path\to\protobuf\cmake\build\debug>nmake check
也可以通过VS
10、安装
C:\Path\to\protobuf\cmake\build\release>nmake install
或
C:\Path\to\protobuf\cmake\build\debug>nmake install
成功!!!
11、如果你想在libprotobuf中包含GzipInputStream与GzipOutputStream
(google/protobuf/io/gzip_stream.h),
Make sure zlib’s two headers are in your
C:\Path\to\install\includepath
Make sure zlib’s linking libraries (*.lib file) is in your
C:\Path\to\install\liblibrary path.
下载
C:\Path\to>git clone -b v1.2.8 https://github.com/madler/zlib.git
C:\Path\to>cd zlib
编译与安装
C:\Path\to\zlib>mkdir build & cd build
C:\Path\to\zlib\build>mkdir release & cd release
C:\Path\to\zlib\build\release>cmake -G “NMake Makefiles” -DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX=../../../install ../..
C:\Path\to\zlib\build\release>nmake & nmake install
当然也可以是debug
12、Now add bin folder from install to system PATH:
C:\Path\to>set PATH=%PATH%;C:\Path\to\install\bin
相关文章推荐
- win7 vs2015编译protobuf-3.1.0
- vs2015编译protobuf-3.1.0
- vs2015编译使用protobuf库图文并茂非常详细
- Win7 vs2015编译protobuf-3.0.0
- protobuf vs2015编译
- boost.asio openssl zlib protobuf icu vs2015编译
- Win7 vs2015编译protobuf-3.0.0
- google/protobuf--VS2015编译、使用
- vs2015编译protobuf-3.1.0
- google/protobuf--VS2015编译、使用
- vs2015编译protobuf-3.1.0
- VS2015配置海康威视SDK环境报错“编译提示应输入字符串文本”怎么办
- 用Cygwin把Protobuf编译到安卓环境下
- vc2015编译protobuf
- caffe搭建--vs2015+caffe+python3.5编译环境的搭建
- VS2015 Qt5.9环境下QtFtp静态库编译及使用
- Win7 VS2015环境编译NanoVG
- 【protobuf 002】 protobuf+vs2013编译安装
- protobuf windows java 环境搭建(编译出protobuf需要的jar包,解决编译时OutOfMemory的问题)