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