Tools Required: CMake for Windows and git for Windows
Principle: Protobuf is a Google Open source project, its source code on GitHub can be downloaded to, and the source is used CMake to build, so we can download the source to local, and then use CMake build Local project, and then compile.
Step one: Download the source code
Copy the following code, save it to the Download_protobuf_source.bat file, and run it
::Reference article https://github.com/google/protobuf/blob/master/cmake/README.md::The default current operating system has git and cmake installed, and environment variables are configuredEcho off& Color 0A::set the required PROTOBUF version, the latest version can be found on GitHub https://github.com/google/protobufSetprotobuf_vesion= "3.0.0-beta-4"Echo%protobuf_vesion%SetProtobuf_path= "protobuf_%protobuf_vesion%"Echo%protobuf_path%::pull Protobuf Source code from GithugGit clone-b%protobuf_vesion% https://github.com/google/protobuf.git%protobuf_path%::pull Gmock from GitHubCD%protobuf_path%git clone-b release-1.7.0 Https://github.com/google/googlemock.git gmock::pull gtest from GitHubCDgmockgit clone-b release-1.7.0 https://github.com/google/googletest.git gtestPause
Step two: Compile
You can use CMake to build the version you need, and here's an example of building and compiling a VS2013 version of Protobuf
Example: Building a VS2013 version
Copy the following code, save to the Build_vs.bat file, place it in the Download_protobuf_source.bat sibling directory, and then execute
For example
::Reference article https://github.com/google/protobuf/blob/master/cmake/README.md::The default current operating system has git and cmake installed, and environment variables are configuredEcho off& Color 0A::set the required PROTOBUF version, the latest version can be found on GitHub https://github.com/google/protobuf::must be consistent with the downloaded versionSetprotobuf_vesion= "3.0.0-beta-4"Echo%protobuf_vesion%SetProtobuf_path= "protobuf_%protobuf_vesion%"Echo%protobuf_path%CD%protobuf_path%::Set the VS Toolset, equivalent to the specified VS version, depending on the VS installation pathSetVs_dev_cmd= "D:\Program Files (x86) \microsoft Visual Studio 12.0\common7\tools\vsdevcmd.bat"::set the project folder name to distinguish between different vs versionsSetBuild_path= "build_vs2013"::set the compiled version of Debug Or releaseSet MODE= "Release"CDCMakeif not exist%build_path%MD%build_path%CD%build_path%if not exist%MODE%MD%MODE%CD%MODE%::start building and compilingPager%vs_dev_cmd%cmake.. /.. /g "NMake makefiles"-dcmake_build_type=%MODE%PagerExtract_includes.Batnmake/F MakefileEcho%CD%Pause
When the progress reaches 100%, the compilation is completed
At this point, everything has been generated, including the header files and Lib files
One-click compilation of various versions of PROTOBUF on Windows