@@ -5,26 +5,31 @@ Copyright 2008 Google Inc.
5
5
6
6
https://developers.google.com/protocol-buffers/
7
7
8
- C++ Installation - Unix
8
+ CMake Installation
9
+ -----------------------
10
+
11
+ To compile or install protobuf from source using CMake, see
12
+ [ cmake/README.md] ( ../cmake/README.md ) .
13
+
14
+ C++ Protobuf - Unix
9
15
-----------------------
10
16
11
17
To build protobuf from source, the following tools are needed:
12
18
13
- * autoconf
14
- * automake
15
- * libtool
16
- * make
19
+ * bazel
20
+ * git
17
21
* g++
18
- * unzip
19
22
20
- On Ubuntu/Debian, you can install them with:
23
+ On Ubuntu/Debian, for example, you can install them with:
21
24
22
- sudo apt-get install autoconf automake libtool curl make g++ unzip
25
+ sudo apt-get install g++ git bazel
23
26
24
27
On other platforms, please use the corresponding package managing tool to
25
- install them before proceeding.
28
+ install them before proceeding. See https://bazel.build/install for further
29
+ instructions on installing Bazel, or to build from source using CMake, see
30
+ [ cmake/README.md] ( ../cmake/README.md ) .
26
31
27
- To get the source, download one of the release .tar.gz or .zip packages in the
32
+ To get the source, download the release .tar.gz or .zip package in the
28
33
release page:
29
34
30
35
https://github.com/protocolbuffers/protobuf/releases/latest
@@ -41,79 +46,23 @@ if you are using a release .tar.gz or .zip package):
41
46
git clone https://github.com/protocolbuffers/protobuf.git
42
47
cd protobuf
43
48
git submodule update --init --recursive
44
- ./autogen.sh
45
-
46
- To build and install the C++ Protocol Buffer runtime and the Protocol
47
- Buffer compiler (protoc) execute the following:
48
-
49
49
50
- ./configure
51
- make -j$(nproc) # $(nproc) ensures it uses all cores for compilation
52
- make check
53
- sudo make install
54
- sudo ldconfig # refresh shared library cache.
50
+ To build the C++ Protocol Buffer runtime and the Protocol Buffer compiler
51
+ (protoc) execute the following:
55
52
56
- If "make check" fails, you can still install, but it is likely that
57
- some features of this library will not work correctly on your system.
58
- Proceed at your own risk.
53
+ bazel build :protoc :protobuf
59
54
60
- For advanced usage information on configure and make, please refer to the
61
- autoconf documentation:
55
+ The compiler can then be installed, for example on Linux:
62
56
63
- http://www.gnu.org/software/autoconf/manual/autoconf.html#Running-configure-Scripts
57
+ cp bazel-bin/protoc /usr/local/bin
64
58
65
- ** Hint on install location**
66
-
67
- By default, the package will be installed to /usr/local. However,
68
- on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH.
69
- You can add it, but it may be easier to just install to /usr
70
- instead. To do this, invoke configure as follows:
71
-
72
- ./configure --prefix=/usr
73
-
74
- If you already built the package with a different prefix, make sure
75
- to run "make clean" before building again.
59
+ For more usage information on Bazel, please refer to http://bazel.build .
76
60
77
61
** Compiling dependent packages**
78
62
79
- To compile a package that uses Protocol Buffers, you need to pass
80
- various flags to your compiler and linker. As of version 2.2.0,
81
- Protocol Buffers integrates with pkg-config to manage this. If you
82
- have pkg-config installed, then you can invoke it to get a list of
83
- flags like so:
84
-
85
-
86
- pkg-config --cflags protobuf # print compiler flags
87
- pkg-config --libs protobuf # print linker flags
88
- pkg-config --cflags --libs protobuf # print both
89
-
90
-
91
- For example:
92
-
93
- c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`
94
-
95
- Note that packages written prior to the 2.2.0 release of Protocol
96
- Buffers may not yet integrate with pkg-config to get flags, and may
97
- not pass the correct set of flags to correctly link against
98
- libprotobuf. If the package in question uses autoconf, you can
99
- often fix the problem by invoking its configure script like:
100
-
101
-
102
- configure CXXFLAGS="$(pkg-config --cflags protobuf)" \
103
- LIBS="$(pkg-config --libs protobuf)"
104
-
105
- This will force it to use the correct flags.
106
-
107
- If you are writing an autoconf-based package that uses Protocol
108
- Buffers, you should probably use the PKG_CHECK_MODULES macro in your
109
- configure script like:
110
-
111
- PKG_CHECK_MODULES([protobuf], [protobuf])
112
-
113
- See the pkg-config man page for more info.
114
-
115
- If you only want protobuf-lite, substitute "protobuf-lite" in place
116
- of "protobuf" in these examples.
63
+ To compile a package that uses Protocol Buffers, you need to setup a Bazel
64
+ WORKSPACE that's hooked up to the protobuf repository and loads its
65
+ dependencies. For an example, see [ WORKSPACE] ( ../examples/WORKSPACE ) .
117
66
118
67
** Note for Mac users**
119
68
@@ -127,64 +76,16 @@ To install Unix tools, you can install "port" following the instructions at
127
76
https://www.macports.org . This will reside in /opt/local/bin/port for most
128
77
Mac installations.
129
78
130
- sudo /opt/local/bin/port install autoconf automake libtool
79
+ sudo /opt/local/bin/port install bazel
131
80
132
81
Alternative for Homebrew users:
133
82
134
- brew install autoconf automake libtool
83
+ brew install bazel
135
84
136
85
Then follow the Unix instructions above.
137
86
138
- ** Note for cross-compiling**
139
-
140
- The makefiles normally invoke the protoc executable that they just
141
- built in order to build tests. When cross-compiling, the protoc
142
- executable may not be executable on the host machine. In this case,
143
- you must build a copy of protoc for the host machine first, then use
144
- the --with-protoc option to tell configure to use it instead. For
145
- example:
146
-
147
- ./configure --with-protoc=protoc
148
-
149
- This will use the installed protoc (found in your $PATH) instead of
150
- trying to execute the one built during the build process. You can
151
- also use an executable that hasn't been installed. For example, if
152
- you built the protobuf package for your host machine in ../host,
153
- you might do:
154
-
155
- ./configure --with-protoc=../host/src/protoc
156
-
157
- Either way, you must make sure that the protoc executable you use
158
- has the same version as the protobuf source code you are trying to
159
- use it with.
160
-
161
- ** Note for Solaris users**
162
-
163
- Solaris 10 x86 has a bug that will make linking fail, complaining
164
- about libstdc++.la being invalid. We have included a work-around
165
- in this package. To use the work-around, run configure as follows:
166
-
167
- ./configure LDFLAGS=-L$PWD/src/solaris
168
-
169
- See src/solaris/libstdc++.la for more info on this bug.
170
87
171
- ** Note for HP C++ Tru64 users**
172
-
173
- To compile invoke configure as follows:
174
-
175
- ./configure CXXFLAGS="-O -std ansi -ieee -D__USE_STD_IOSTREAM"
176
-
177
- Also, you will need to use gmake instead of make.
178
-
179
- ** Note for AIX users**
180
-
181
- Compile using the IBM xlC C++ compiler as follows:
182
-
183
- ./configure CXX=xlC
184
-
185
- Also, you will need to use GNU ` make ` (` gmake ` ) instead of AIX ` make ` .
186
-
187
- C++ Installation - Windows
88
+ C++ Protobuf - Windows
188
89
--------------------------
189
90
190
91
If you only need the protoc binary, you can download it from the release
@@ -220,15 +121,15 @@ That is, if you linked an executable against an older version of
220
121
libprotobuf, it is unlikely to work with a newer version without
221
122
re-compiling. This problem, when it occurs, will normally be detected
222
123
immediately on startup of your app. Still, you may want to consider
223
- using static linkage. You can configure this package to install
224
- static libraries only using :
124
+ using static linkage. You can configure this in your ` cc_binary ` Bazel rules
125
+ by specifying :
225
126
226
- ./configure --disable-shared
127
+ linkstatic=True
227
128
228
129
Usage
229
130
-----
230
131
231
132
The complete documentation for Protocol Buffers is available via the
232
133
web at:
233
134
234
- https://developers.google.com/protocol-buffers /
135
+ https://protobuf.dev /
0 commit comments