Removed obsolete compatibility code from Bazel rules.
[google-protobuf.git] / src / README.md
blob8977d0da258cdffc648b5f180ded90ba6249292a
1 Protocol Buffers - Google's data interchange format
2 ===================================================
4 Copyright 2008 Google Inc.
6 https://developers.google.com/protocol-buffers/
8 CMake Installation
9 -----------------------
11 To compile or install protobuf from source using CMake, see
12 [cmake/README.md](../cmake/README.md).
14 C++ Protobuf - Unix
15 -----------------------
17 To build protobuf from source, the following tools are needed:
19   * bazel
20   * git
21   * g++
22   * Abseil
24 On Ubuntu/Debian, for example, you can install them with:
26     sudo apt-get install g++ git bazel
28 On other platforms, please use the corresponding package managing tool to
29 install them before proceeding.  See https://bazel.build/install for further
30 instructions on installing Bazel, or to build from source using CMake, see
31 [cmake/README.md](../cmake/README.md). See https://github.com/abseil/abseil-cpp
32 for instructions on installing Abseil.
34 To get the source, download the release .tar.gz or .zip package in the
35 release page:
37     https://github.com/protocolbuffers/protobuf/releases/latest
39 You can also get the source by "git clone" our git repository. Make sure you
40 have also cloned the submodules and generated the configure script (skip this
41 if you are using a release .tar.gz or .zip package):
43     git clone https://github.com/protocolbuffers/protobuf.git
44     cd protobuf
45     git submodule update --init --recursive
47 To build the C++ Protocol Buffer runtime and the Protocol Buffer compiler
48 (protoc) execute the following:
50     bazel build :protoc :protobuf
52 The compiler can then be installed, for example on Linux:
54     cp bazel-bin/protoc /usr/local/bin
56 For more usage information on Bazel, please refer to http://bazel.build.
58 **Compiling dependent packages**
60 To compile a package that uses Protocol Buffers, you need to setup a Bazel
61 WORKSPACE that's hooked up to the protobuf repository and loads its
62 dependencies.  For an example, see [WORKSPACE](../examples/WORKSPACE).
64 **Note for Mac users**
66 For a Mac system, Unix tools are not available by default. You will first need
67 to install Xcode from the Mac AppStore and then run the following command from
68 a terminal:
70     sudo xcode-select --install
72 To install Unix tools, you can install "port" following the instructions at
73 https://www.macports.org . This will reside in /opt/local/bin/port for most
74 Mac installations.
76     sudo /opt/local/bin/port install bazel
78 Alternative for Homebrew users:
80     brew install bazel
82 Then follow the Unix instructions above.
85 C++ Protobuf - Windows
86 --------------------------
88 If you only need the protoc binary, you can download it from the release
89 page:
91     https://github.com/protocolbuffers/protobuf/releases/latest
93 In the downloads section, download the zip file protoc-$VERSION-win32.zip.
94 It contains the protoc binary as well as public proto files of protobuf
95 library.
97 Protobuf and its dependencies can be installed directly by using `vcpkg`:
99     >vcpkg install protobuf protobuf:x64-windows
101 If zlib support is desired, you'll also need to install the zlib feature:
103     >vcpkg install protobuf[zlib] protobuf[zlib]:x64-windows
105 See https://github.com/Microsoft/vcpkg for more information.
107 To build from source using Microsoft Visual C++, see [cmake/README.md](../cmake/README.md).
109 To build from source using Cygwin or MinGW, follow the Unix installation
110 instructions, above.
112 Binary Compatibility Warning
113 ----------------------------
115 Due to the nature of C++, it is unlikely that any two versions of the
116 Protocol Buffers C++ runtime libraries will have compatible ABIs.
117 That is, if you linked an executable against an older version of
118 libprotobuf, it is unlikely to work with a newer version without
119 re-compiling.  This problem, when it occurs, will normally be detected
120 immediately on startup of your app.  Still, you may want to consider
121 using static linkage.  You can configure this in your `cc_binary` Bazel rules
122 by specifying:
124     linkstatic=True
126 Usage
127 -----
129 The complete documentation for Protocol Buffers is available via the
130 web at:
132 https://protobuf.dev/