protobuf-3.0.0-beta-2 windows编译 x64/x86
V3.0.0 beta2以及之后都是CMake 创建VS Solution,project。 因为只能创建x64的项目工程,有时候需要x86的, 只能创建完x64后,自己修改工程配置弄成x86。
创建步骤参考 protobuf-3.0.0-beta-2/cmake/readme.md
C:\Path\to\protobuf\cmake\build>mkdir release & cd release
C:\Path\to\protobuf\cmake\build\release>cmake -G "NMake Makefiles" ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
C:\Path\to\protobuf\cmake\build>mkdir debug & cd debug
C:\Path\to\protobuf\cmake\build\debug>cmake -G "NMake Makefiles" ^
-DCMAKE_BUILD_TYPE=Debug ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
C:\Path\to\protobuf\cmake\build>mkdir solution & cd solution
C:\Path\to\protobuf\cmake\build\solution>cmake -G "Visual Studio 14 2015 Win64" ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
cmake -G "Visual Studio 14 2015 Win64" ^
这里cmake只能创建x64的工程属性,要不然是ARM的。 参考 https://cmake.org/cmake/help/v3.3/generator/Visual Studio 14 2015.html
只能生成x64的之后,在VS工程属性中 【Link】
修改
【TargetMachine】
【addition options】
release 默认, debug 有debug
x86 ,x64
都有不同,看下拉设置。
To compile protobuf:
C:\Path\to\protobuf\cmake\build\release>nmake
or
C:\Path\to\protobuf\cmake\build\debug>nmake
Testing
To run unit-tests:
C:\Path\to\protobuf\cmake\build\release>nmake check
or
C:\Path\to\protobuf\cmake\build\debug>nmake check
Installing
To install protobuf to the specified install folder:
C:\Path\to\protobuf\cmake\build\release>nmake install
or
C:\Path\to\protobuf\cmake\build\debug>nmake install