V3.0.0 beta2以及以后都是CMake 建立VS Solution,project。 由于只能建立x64的项目工程,有时候须要x86的, 只能建立完x64后,本身修改工程配置弄成x86。html
建立步骤参考 protobuf-3.0.0-beta-2/cmake/readme.mdbash
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%20Studio%2014%202015.htmlui
只能生成x64的以后,在VS工程属性中 【Link】
修改
【TargetMachine】
【addition options】debug
release 默认, debug 有debugcode
x86 ,x64htm
都有不一样,看下拉设置。ci
To compile protobuf:get
C:\Path\to\protobuf\cmake\build\release>nmake
orgenerator
C:\Path\to\protobuf\cmake\build\debug>nmake
it
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