This directory contains *CMake* files that can be used to build protobuf
with *MSVC* on *Windows*. You can build the project from *Command Prompt*
and using an *Visual Studio* IDE.
You need to have [CMake](http://www.cmake.org), [Visual Studio](https://www.visualstudio.com)
and optionally [Git](http://git-scm.com) installed on your computer before proceeding.
Most of the instructions will be given to the *小ommand Prompt*, but the same
actions can be performed using appropriate GUI tools.
Environment Setup
=================
Open the appropriate *Command Prompt* from the *Start* menu.
For example *VS2013 x64 Native Tools Command Prompt*:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64>
Change to your working directory:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64>cd C:\Path\to
C:\Path\to>
Where *C:\Path\to* is path to your real working directory.
Create a folder where protobuf headers/libraries/binaries will be installed after built:
C:\Path\to>mkdir install
If *cmake* command is not available from *Command Prompt*, add it to system *PATH* variable:
C:\Path\to>set PATH=%PATH%;C:\Program Files (x86)\CMake\bin
If *git* command is not available from *Command Prompt*, add it to system *PATH* variable:
C:\Path\to>set PATH=%PATH%;C:\Program Files\Git\cmd
Good. Now you are ready to continue.
Getting Sources
===============
You can get the latest stable source packages from the release page:
https://github.com/google/protobuf/releases/latest
For example: if you only need C++, download `protobuf-cpp-[VERSION].tar.gz`; if
you need C++ and Java, download `protobuf-java-[VERSION].tar.gz` (every package
contains C++ source already); if you need C++ and multiple other languages,
download `protobuf-all-[VERSION].tar.gz`.
Or you can use git to clone from protobuf git repository.
C:\Path\to> git clone -b [release_tag] https://github.com/google/protobuf.git
Where *[release_tag]* is a git tag like *v3.0.0-beta-1* or a branch name like *master*
if you want to get the latest code.
Go to the project folder:
C:\Path\to>cd protobuf
C:\Path\to\protobuf>
Remember to update any submodules if you are using git clone (you can skip this
step if you are using a release .tar.gz or .zip package):
```console
C:\Path\to> git submodule update --init --recursive
```
Now go to *cmake* folder in protobuf sources:
C:\Path\to\protobuf>cd cmake
C:\Path\to\protobuf\cmake>
Good. Now you are ready to *CMake* configuration.
CMake Configuration
===================
*CMake* supports a lot of different
[generators](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html)
for various native build systems.
We are only interested in
[Makefile](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html#makefile-generators)
and
[Visual Studio](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators)
generators.
We will use shadow building to separate the temporary files from the protobuf source code.
Create a temporary *build* folder and change your working directory to it:
C:\Path\to\protobuf\cmake>mkdir build & cd build
C:\Path\to\protobuf\cmake\build>
The *Makefile* generator can build the project in only one configuration, so you need to build
a separate folder for each configuration.
To start using a *Release* configuration:
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 ^
../..
It will generate *nmake* *Makefile* in current directory.
To use *Debug* configuration:
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 ^
../..
It will generate *nmake* *Makefile* in current directory.
To create *Visual Studio* solution file:
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 ^
../..
It will generate *Visual Studio* solution file *protobuf.sln* in current directory.
If the *gmock* directory does not exist, and you do not want to build protobuf unit tests,
you need to add *cmake* command argument `-Dprotobuf_BUILD_TESTS=OFF` to disable testing.
Compiling
=========
To compile protobuf:
C:\Path\to\protobuf\cmake\build\release>nmake
or
C:\Path\to\protobuf\cmake\build\debug>nmake
And wait for the compilation to finish.
If you prefer to use the IDE:
* Open the generated protobuf.sln file in Microsoft Visual Studio.
* Choose "Debug" or "Release" configuration as desired.
* From the Build menu, choose "Build Solution".
And wait for the compilation to finish.
Testing
=======
To run unit-tests, first you must compile protobuf as described above.
Then run:
C:\Path\to\protobuf\cmake\build\release>nmake check
or
C:\Path\to\protobuf\cmake\build\debug>nmake check
You can also build project *check* from Visual Studio solution.
Yes, it may sound strange, but it works.
You should see output similar to:
Running main() from gmock_main.cc
[==========] Running 1546 tests from 165 test cases.
...
[==========] 1546 tests from 165 test cases ran. (2529 ms total)
[ PASSED ] 1546 tests.
To run specific tests:
C:\Path\to\protobuf>cmake\build\release\tests.exe --gtest_filter=AnyTest*
Running main() from gmock_main.cc
Note: Google Test filter = AnyTest*
[==========] Running 3 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 3 tests from AnyTest
[ RUN ] AnyTest.TestPackAndUnpack
[ OK ] AnyTest.TestPackAndUnpack (0 ms)
[ RUN ] AnyTest.TestPackAndUnpackAny
[ OK ] AnyTest.TestPackAndUnpackAny (0 ms)
[ RUN ] AnyTest.TestIs
[ OK ] AnyTest.TestIs (0 ms)
[----------] 3 tests from AnyTest (1 ms total)
[----------] Global test environment tear-down
[==========] 3 tests from 1 test case ran. (2 ms total)
[ PASSED ] 3 tests.
Note that the tests must be run from the source folder.
If all tests are passed, safely continue.
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
You can also build project *INSTALL* from Visual Studio solution.
It sounds not so strange and it works.
This will create the following folders under the *install* location:
* bin - that contains protobuf *protoc.exe* compiler;
* include - that contains C++ headers and protobuf *.proto files;
* lib - that contains linking libraries and *CMake* configuration files for *protobuf* package.
Now you can if needed:
* Copy the contents of the include directory to wherever you want to put headers.
* Copy protoc.exe wherever you put build tools (probably somewhere in your PATH).
* Copy linking libraries libprotobuf[d].lib, libprotobuf-lite[d].lib, and libprotoc[d].lib wherever you put libraries.
To avoid conflicts between the MSVC debug and release runtime libraries, when
compiling a debug build of your application, you may need to link against a
debug build of libprotobufd.lib with "d" postfix. Similarly, release builds should link against
release libprotobuf.lib library.
DLLs vs. static linking
=======================
Static linking is now the default for the Protocol Buffer libraries. Due to
issues with Win32's use of a separate heap for each DLL, as well as binary
compatibility issues between different versions of MSVC's STL library, it is
recommended that you use static linkage only. H
没有合适的资源?快使用搜索试试~ 我知道了~
protobuf-python-3.6.1
共1067个文件
cc:366个
h:288个
py:87个
需积分: 45 33 下载量 183 浏览量
2019-02-14
18:21:25
上传
评论
收藏 5.56MB ZIP 举报
温馨提示
官方protobuf所有都在,如果后面更新了版本,只需要更改后的v.几版本,前面的版本都可以下载,这里是最新的。面向python。 对于很多不能访问Google,这个要方便多了。不过网速很慢,给大家提供下载
资源推荐
资源详情
资源评论
收起资源包目录
protobuf-python-3.6.1 (1067个子文件)
configure.ac 7KB
configure.ac 6KB
configure.ac 3KB
configure.ac 461B
Makefile.am 78KB
Makefile.am 52KB
Makefile.am 35KB
Makefile.am 22KB
Makefile.am 11KB
Makefile.am 7KB
Makefile.am 315B
ar-lib 6KB
bad_utf8_string 3B
BUILD.bazel 4KB
BUILD 34KB
BUILD 3KB
BUILD 765B
six.BUILD 227B
protobuf.bzl 13KB
gtest.cbproj 10KB
gtest_unittest.cbproj 9KB
gtest_main.cbproj 8KB
descriptor.pb.cc 551KB
gmock-gtest-all.cc 441KB
gtest-all.cc 372KB
descriptor_unittest.cc 285KB
descriptor.cc 271KB
gtest_unittest.cc 242KB
gtest.cc 193KB
gmock-matchers_test.cc 179KB
cpp_message.cc 153KB
js_generator.cc 126KB
map_test.cc 117KB
parser_unittest.cc 108KB
type.pb.cc 103KB
message_differencer_unittest.cc 102KB
message.cc 102KB
wrappers.pb.cc 98KB
test_util_lite.cc 89KB
conformance_test.cc 89KB
generated_message_reflection.cc 89KB
protostream_objectwriter_test.cc 85KB
command_line_interface_unittest.cc 81KB
strutil.cc 80KB
parser.cc 77KB
text_format.cc 77KB
command_line_interface.cc 77KB
map_test_util.cc 76KB
gtest_pred_impl_unittest.cc 76KB
extension_set.cc 73KB
gmock-spec-builders_test.cc 71KB
plugin.pb.cc 69KB
descriptor.cc 69KB
message_differencer.cc 64KB
text_format_unittest.cc 64KB
api.pb.cc 61KB
repeated_field_unittest.cc 55KB
python_generator.cc 54KB
objectivec_helpers.cc 54KB
wire_format.cc 54KB
java_message.cc 54KB
struct.pb.cc 53KB
extension_set_unittest.cc 53KB
gtest-printers_test.cc 53KB
descriptor_containers.cc 52KB
php_generator.cc 52KB
arena_unittest.cc 51KB
cpp_file.cc 50KB
gtest-death-test.cc 49KB
coded_stream_unittest.cc 48KB
wire_format_unittest.cc 47KB
java_message_field.cc 46KB
cpp_string_field.cc 45KB
gmock-actions_test.cc 44KB
gtest-death-test_test.cc 43KB
protostream_objectwriter.cc 43KB
gmock-generated-matchers_test.cc 42KB
gtest-port.cc 41KB
java_message_lite.cc 41KB
protostream_objectsource.cc 41KB
generated_message_reflection_unittest.cc 41KB
gmock-generated-actions_test.cc 40KB
gtest-port_test.cc 39KB
gtest-param-test_test.cc 37KB
java_string_field.cc 37KB
map_container.cc 37KB
tokenizer.cc 37KB
tokenizer_unittest.cc 37KB
java_enum_field.cc 36KB
java_enum_field_lite.cc 36KB
java_message_field_lite.cc 35KB
java_map_field_lite.cc 35KB
java_string_field_lite.cc 34KB
lite_unittest.cc 33KB
protostream_objectsource_test.cc 33KB
java_primitive_field_lite.cc 33KB
field_mask_util_test.cc 32KB
gtest_output_test_.cc 32KB
java_primitive_field.cc 32KB
dynamic_message.cc 32KB
共 1067 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
资源评论
地瓜233号
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功