One: Overview
About Protobuf No more here, the successful compilation steps are documented here for later review.
Note: This article is not compiled using the CMake GUI, and if you are familiar with the CMake GUI, you can also use the GUI to generate the compilation.
II: Preparation of resources and tools
- VS2013 or above, install well
- Protobuf Source code,:
Official website: http://code.google.com/p/protobuf/
git Web: https://github.com/google/protobuf
or git:https://github.com/google/protobuf/releases
Individual is the last address downloaded, the download package is at the end of: Source code (Zip) Full package
- CMake, download and install.
- Note: If you need to compile gtest, you will also need to download Gmock and gtest related resource packs from the officer network or GIT. (In the morning these two packages seem to be separate, now the new version, read the readme description, Gmock like has been integrated into the gtest). I do not need gtest, so do not download.
Three: Environment configuration
- After installing the CMake, open the cmd window and enter CMake--version to check if CMake is installed correctly. If you are prompted with an error, you will need to manually configure the CMake into the system environment variable
- Unzip the download good protobuf source full package. (If extracted to here: i:\dev\c++\, therefore, my PROTOBF resources are located at: i:\dev\c++\protobuf-3.3.0)
Four: Compiling protobuf
- Open the VS2013 x64 Local tool command Prompt (because the x64 version is compiled by the individual)
- CD I:\dev\c++\protobuf-3.3.0\cmake
- mkdir Build & CD Build
- mkdir Debug & CD Debug
Tip: To compile release version, just mkdir release & CD release. This step simply creates a debug (or release) directory that holds the CMake file configuration information related to generating debug (or release). After performing steps 3 and 4, the current path is: i:\dev\c++\protobuf-3.3.0\cmake\build\release
- Cmake-g "NMake makefiles"-dcmake_build_type=release-dprotobuf_build_tests=off-dcmake_install_prefix=. /.. /.. /install. /..
Wait a moment for the makefile-related configuration text to complete. If there are no prompt errors, continue with the next steps
- Nmake
Wait a moment again for Protobuf (the corresponding debug or release version) to compile. If there are no prompt errors, continue with the next steps
- NMAKE Install
Wait a moment again for the installation to complete. If there is no prompt error, an install directory will be generated in the i:\dev\c++\protobuf-3.3.0 directory with the bin directory, the Lib directory, the Include directory, and a cmake directory. Useful for development is primarily the first three directories.
- Tip: After the final generation of debug and release (if one is generated at the same time), then their include directory is exactly the same. Therefore, whether you are generating debug or release or both, you can do this in exactly the previous 7 steps.
Protobuf v3.3.0 under Windows compilation