OLD | NEW |
1 Protocol Buffers - Google's data interchange format | 1 Protocol Buffers - Google's data interchange format |
2 =================================================== | |
3 | |
4 [](https
://travis-ci.org/google/protobuf) [](https://ci.appveyor.com/project/proto
buf/protobuf) | |
5 | |
6 Copyright 2008 Google Inc. | 2 Copyright 2008 Google Inc. |
7 | 3 http://code.google.com/apis/protocolbuffers/ |
8 https://developers.google.com/protocol-buffers/ | |
9 | 4 |
10 C++ Installation - Unix | 5 C++ Installation - Unix |
11 ----------------------- | 6 ======================= |
12 | |
13 If you get the source from github, you need to generate the configure script | |
14 first: | |
15 | |
16 $ ./autogen.sh | |
17 | |
18 This will download gmock source (which is used for C++ Protocol Buffer | |
19 unit-tests) to the current directory and run automake, autoconf, etc. | |
20 to generate the configure script and various template makefiles. | |
21 | |
22 You can skip this step if you are using a release package (which already | |
23 contains gmock and the configure script). | |
24 | 7 |
25 To build and install the C++ Protocol Buffer runtime and the Protocol | 8 To build and install the C++ Protocol Buffer runtime and the Protocol |
26 Buffer compiler (protoc) execute the following: | 9 Buffer compiler (protoc) execute the following: |
27 | 10 |
28 $ ./configure | 11 $ ./configure |
29 $ make | 12 $ make |
30 $ make check | 13 $ make check |
31 $ make install | 14 $ make install |
32 | 15 |
33 If "make check" fails, you can still install, but it is likely that | 16 If "make check" fails, you can still install, but it is likely that |
34 some features of this library will not work correctly on your system. | 17 some features of this library will not work correctly on your system. |
35 Proceed at your own risk. | 18 Proceed at your own risk. |
36 | 19 |
37 "make install" may require superuser privileges. | 20 "make install" may require superuser privileges. |
38 | 21 |
39 For advanced usage information on configure and make, see INSTALL.txt. | 22 For advanced usage information on configure and make, see INSTALL.txt. |
40 | 23 |
41 **Hint on install location** | 24 ** Hint on install location ** |
42 | 25 |
43 By default, the package will be installed to /usr/local. However, | 26 By default, the package will be installed to /usr/local. However, |
44 on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH. | 27 on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH. |
45 You can add it, but it may be easier to just install to /usr | 28 You can add it, but it may be easier to just install to /usr |
46 instead. To do this, invoke configure as follows: | 29 instead. To do this, invoke configure as follows: |
47 | 30 |
48 ./configure --prefix=/usr | 31 ./configure --prefix=/usr |
49 | 32 |
50 If you already built the package with a different prefix, make sure | 33 If you already built the package with a different prefix, make sure |
51 to run "make clean" before building again. | 34 to run "make clean" before building again. |
52 | 35 |
53 **Compiling dependent packages** | 36 ** Compiling dependent packages ** |
54 | 37 |
55 To compile a package that uses Protocol Buffers, you need to pass | 38 To compile a package that uses Protocol Buffers, you need to pass |
56 various flags to your compiler and linker. As of version 2.2.0, | 39 various flags to your compiler and linker. As of version 2.2.0, |
57 Protocol Buffers integrates with pkg-config to manage this. If you | 40 Protocol Buffers integrates with pkg-config to manage this. If you |
58 have pkg-config installed, then you can invoke it to get a list of | 41 have pkg-config installed, then you can invoke it to get a list of |
59 flags like so: | 42 flags like so: |
60 | 43 |
61 pkg-config --cflags protobuf # print compiler flags | 44 pkg-config --cflags protobuf # print compiler flags |
62 pkg-config --libs protobuf # print linker flags | 45 pkg-config --libs protobuf # print linker flags |
63 pkg-config --cflags --libs protobuf # print both | 46 pkg-config --cflags --libs protobuf # print both |
(...skipping 17 matching lines...) Expand all Loading... |
81 Buffers, you should probably use the PKG_CHECK_MODULES macro in your | 64 Buffers, you should probably use the PKG_CHECK_MODULES macro in your |
82 configure script like: | 65 configure script like: |
83 | 66 |
84 PKG_CHECK_MODULES([protobuf], [protobuf]) | 67 PKG_CHECK_MODULES([protobuf], [protobuf]) |
85 | 68 |
86 See the pkg-config man page for more info. | 69 See the pkg-config man page for more info. |
87 | 70 |
88 If you only want protobuf-lite, substitute "protobuf-lite" in place | 71 If you only want protobuf-lite, substitute "protobuf-lite" in place |
89 of "protobuf" in these examples. | 72 of "protobuf" in these examples. |
90 | 73 |
91 **Note for Mac users** | 74 ** Note for cross-compiling ** |
92 | |
93 For a Mac system, Unix tools are not available by default. You will first need | |
94 to install Xcode from the Mac AppStore and then run the following command from | |
95 a terminal: | |
96 | |
97 $ sudo xcode-select --install | |
98 | |
99 To install Unix tools, you can install "port" following the instructions at | |
100 https://www.macports.org . This will reside in /opt/local/bin/port for most | |
101 Mac installations. | |
102 | |
103 $ sudo /opt/local/bin/port install autoconf automake libtool | |
104 | |
105 Then follow the Unix instructions above. | |
106 | |
107 **Note for cross-compiling** | |
108 | 75 |
109 The makefiles normally invoke the protoc executable that they just | 76 The makefiles normally invoke the protoc executable that they just |
110 built in order to build tests. When cross-compiling, the protoc | 77 built in order to build tests. When cross-compiling, the protoc |
111 executable may not be executable on the host machine. In this case, | 78 executable may not be executable on the host machine. In this case, |
112 you must build a copy of protoc for the host machine first, then use | 79 you must build a copy of protoc for the host machine first, then use |
113 the --with-protoc option to tell configure to use it instead. For | 80 the --with-protoc option to tell configure to use it instead. For |
114 example: | 81 example: |
115 | 82 |
116 ./configure --with-protoc=protoc | 83 ./configure --with-protoc=protoc |
117 | 84 |
118 This will use the installed protoc (found in your $PATH) instead of | 85 This will use the installed protoc (found in your $PATH) instead of |
119 trying to execute the one built during the build process. You can | 86 trying to execute the one built during the build process. You can |
120 also use an executable that hasn't been installed. For example, if | 87 also use an executable that hasn't been installed. For example, if |
121 you built the protobuf package for your host machine in ../host, | 88 you built the protobuf package for your host machine in ../host, |
122 you might do: | 89 you might do: |
123 | 90 |
124 ./configure --with-protoc=../host/src/protoc | 91 ./configure --with-protoc=../host/src/protoc |
125 | 92 |
126 Either way, you must make sure that the protoc executable you use | 93 Either way, you must make sure that the protoc executable you use |
127 has the same version as the protobuf source code you are trying to | 94 has the same version as the protobuf source code you are trying to |
128 use it with. | 95 use it with. |
129 | 96 |
130 **Note for Solaris users** | 97 ** Note for Solaris users ** |
131 | 98 |
132 Solaris 10 x86 has a bug that will make linking fail, complaining | 99 Solaris 10 x86 has a bug that will make linking fail, complaining |
133 about libstdc++.la being invalid. We have included a work-around | 100 about libstdc++.la being invalid. We have included a work-around |
134 in this package. To use the work-around, run configure as follows: | 101 in this package. To use the work-around, run configure as follows: |
135 | 102 |
136 ./configure LDFLAGS=-L$PWD/src/solaris | 103 ./configure LDFLAGS=-L$PWD/src/solaris |
137 | 104 |
138 See src/solaris/libstdc++.la for more info on this bug. | 105 See src/solaris/libstdc++.la for more info on this bug. |
139 | 106 |
140 **Note for HP C++ Tru64 users** | 107 ** Note for HP C++ Tru64 users ** |
141 | 108 |
142 To compile invoke configure as follows: | 109 To compile invoke configure as follows: |
143 | 110 |
144 ./configure CXXFLAGS="-O -std ansi -ieee -D__USE_STD_IOSTREAM" | 111 ./configure CXXFLAGS="-O -std ansi -ieee -D__USE_STD_IOSTREAM" |
145 | 112 |
146 Also, you will need to use gmake instead of make. | 113 Also, you will need to use gmake instead of make. |
147 | 114 |
148 **Note for AIX users** | 115 C++ Installation - Windows |
| 116 ========================== |
149 | 117 |
150 Compile using the IBM xlC C++ compiler as follows: | 118 If you are using Microsoft Visual C++, see vsprojects/readme.txt. |
151 | |
152 ./configure CXX=xlC | |
153 | |
154 Also, you will need to use GNU `make` (`gmake`) instead of AIX `make`. | |
155 | |
156 C++ Installation - Windows | |
157 -------------------------- | |
158 | |
159 If you are using Microsoft Visual C++, see cmake/README.md. | |
160 | 119 |
161 If you are using Cygwin or MinGW, follow the Unix installation | 120 If you are using Cygwin or MinGW, follow the Unix installation |
162 instructions, above. | 121 instructions, above. |
163 | 122 |
164 Binary Compatibility Warning | 123 Binary Compatibility Warning |
165 ---------------------------- | 124 ============================ |
166 | 125 |
167 Due to the nature of C++, it is unlikely that any two versions of the | 126 Due to the nature of C++, it is unlikely that any two versions of the |
168 Protocol Buffers C++ runtime libraries will have compatible ABIs. | 127 Protocol Buffers C++ runtime libraries will have compatible ABIs. |
169 That is, if you linked an executable against an older version of | 128 That is, if you linked an executable against an older version of |
170 libprotobuf, it is unlikely to work with a newer version without | 129 libprotobuf, it is unlikely to work with a newer version without |
171 re-compiling. This problem, when it occurs, will normally be detected | 130 re-compiling. This problem, when it occurs, will normally be detected |
172 immediately on startup of your app. Still, you may want to consider | 131 immediately on startup of your app. Still, you may want to consider |
173 using static linkage. You can configure this package to install | 132 using static linkage. You can configure this package to install |
174 static libraries only using: | 133 static libraries only using: |
175 | 134 |
176 ./configure --disable-shared | 135 ./configure --disable-shared |
177 | 136 |
178 Java and Python Installation | 137 Java and Python Installation |
179 ---------------------------- | 138 ============================ |
180 | 139 |
181 The Java and Python runtime libraries for Protocol Buffers are located | 140 The Java and Python runtime libraries for Protocol Buffers are located |
182 in the java and python directories. See the README file in each | 141 in the java and python directories. See the README file in each |
183 directory for more information on how to compile and install them. | 142 directory for more information on how to compile and install them. |
184 Note that both of them require you to first install the Protocol | 143 Note that both of them require you to first install the Protocol |
185 Buffer compiler (protoc), which is part of the C++ package. | 144 Buffer compiler (protoc), which is part of the C++ package. |
186 | 145 |
187 Usage | 146 Usage |
188 ----- | 147 ===== |
189 | 148 |
190 The complete documentation for Protocol Buffers is available via the | 149 The complete documentation for Protocol Buffers is available via the |
191 web at: | 150 web at: |
192 | 151 |
193 https://developers.google.com/protocol-buffers/ | 152 http://code.google.com/apis/protocolbuffers/ |
OLD | NEW |