index.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8'>
  5. <meta http-equiv="X-UA-Compatible" content="chrome=1">
  6. <meta name="description" content="Google Protocol Buffers : ">
  7. <link rel="stylesheet" type="text/css" media="screen" href="stylesheets/stylesheet.css">
  8. <title>Google Protocol Buffers</title>
  9. </head>
  10. <body>
  11. <!-- HEADER -->
  12. <div id="header_wrap" class="outer">
  13. <header class="inner">
  14. <a id="forkme_banner" href="https://github.com/google/protobuf">View on GitHub</a>
  15. <h1 id="project_title">Google Protocol Buffers</h1>
  16. <h2 id="project_tagline"></h2>
  17. <section id="downloads">
  18. <a class="zip_download_link" href="https://github.com/google/protobuf/zipball/master">Download this project as a .zip file</a>
  19. <a class="tar_download_link" href="https://github.com/google/protobuf/tarball/master">Download this project as a tar.gz file</a>
  20. </section>
  21. </header>
  22. </div>
  23. <!-- MAIN CONTENT -->
  24. <div id="main_content_wrap" class="outer">
  25. <section id="main_content" class="inner">
  26. <h1>
  27. <a name="protocol-buffers---googles-data-interchange-format" class="anchor" href="#protocol-buffers---googles-data-interchange-format"><span class="octicon octicon-link"></span></a>Protocol Buffers - Google's data interchange format</h1>
  28. <p>Copyright 2008 Google Inc.</p>
  29. <p><a href="https://developers.google.com/protocol-buffers/">https://developers.google.com/protocol-buffers/</a></p>
  30. <h2>
  31. <a name="c-installation---unix" class="anchor" href="#c-installation---unix"><span class="octicon octicon-link"></span></a>C++ Installation - Unix</h2>
  32. <p>If you get the source from github, you need to generate the configure script
  33. first:</p>
  34. <pre><code>$ ./autogen.sh
  35. </code></pre>
  36. <p>This will download gtest source (which is used for C++ Protocol Buffer
  37. unit-tests) to the current directory and run automake, autoconf, etc.
  38. to generate the configure script and various template makefiles.</p>
  39. <p>You can skip this step if you are using a release package (which already
  40. contains gtest and the configure script).</p>
  41. <p>To build and install the C++ Protocol Buffer runtime and the Protocol
  42. Buffer compiler (protoc) execute the following:</p>
  43. <pre><code>$ ./configure
  44. $ make
  45. $ make check
  46. $ make install
  47. </code></pre>
  48. <p>If "make check" fails, you can still install, but it is likely that
  49. some features of this library will not work correctly on your system.
  50. Proceed at your own risk.</p>
  51. <p>"make install" may require superuser privileges.</p>
  52. <p>For advanced usage information on configure and make, see INSTALL.txt.</p>
  53. <p><strong>Hint on install location</strong></p>
  54. <p>By default, the package will be installed to /usr/local. However,
  55. on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH.
  56. You can add it, but it may be easier to just install to /usr
  57. instead. To do this, invoke configure as follows:</p>
  58. <pre><code>./configure --prefix=/usr
  59. </code></pre>
  60. <p>If you already built the package with a different prefix, make sure
  61. to run "make clean" before building again.</p>
  62. <p><strong>Compiling dependent packages</strong></p>
  63. <p>To compile a package that uses Protocol Buffers, you need to pass
  64. various flags to your compiler and linker. As of version 2.2.0,
  65. Protocol Buffers integrates with pkg-config to manage this. If you
  66. have pkg-config installed, then you can invoke it to get a list of
  67. flags like so:</p>
  68. <pre><code>pkg-config --cflags protobuf # print compiler flags
  69. pkg-config --libs protobuf # print linker flags
  70. pkg-config --cflags --libs protobuf # print both
  71. </code></pre>
  72. <p>For example:</p>
  73. <pre><code>c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`
  74. </code></pre>
  75. <p>Note that packages written prior to the 2.2.0 release of Protocol
  76. Buffers may not yet integrate with pkg-config to get flags, and may
  77. not pass the correct set of flags to correctly link against
  78. libprotobuf. If the package in question uses autoconf, you can
  79. often fix the problem by invoking its configure script like:</p>
  80. <pre><code>configure CXXFLAGS="$(pkg-config --cflags protobuf)" \
  81. LIBS="$(pkg-config --libs protobuf)"
  82. </code></pre>
  83. <p>This will force it to use the correct flags.</p>
  84. <p>If you are writing an autoconf-based package that uses Protocol
  85. Buffers, you should probably use the PKG_CHECK_MODULES macro in your
  86. configure script like:</p>
  87. <pre><code>PKG_CHECK_MODULES([protobuf], [protobuf])
  88. </code></pre>
  89. <p>See the pkg-config man page for more info.</p>
  90. <p>If you only want protobuf-lite, substitute "protobuf-lite" in place
  91. of "protobuf" in these examples.</p>
  92. <p><strong>Note for cross-compiling</strong></p>
  93. <p>The makefiles normally invoke the protoc executable that they just
  94. built in order to build tests. When cross-compiling, the protoc
  95. executable may not be executable on the host machine. In this case,
  96. you must build a copy of protoc for the host machine first, then use
  97. the --with-protoc option to tell configure to use it instead. For
  98. example:</p>
  99. <pre><code>./configure --with-protoc=protoc
  100. </code></pre>
  101. <p>This will use the installed protoc (found in your $PATH) instead of
  102. trying to execute the one built during the build process. You can
  103. also use an executable that hasn't been installed. For example, if
  104. you built the protobuf package for your host machine in ../host,
  105. you might do:</p>
  106. <pre><code>./configure --with-protoc=../host/src/protoc
  107. </code></pre>
  108. <p>Either way, you must make sure that the protoc executable you use
  109. has the same version as the protobuf source code you are trying to
  110. use it with.</p>
  111. <p><strong>Note for Solaris users</strong></p>
  112. <p>Solaris 10 x86 has a bug that will make linking fail, complaining
  113. about libstdc++.la being invalid. We have included a work-around
  114. in this package. To use the work-around, run configure as follows:</p>
  115. <pre><code>./configure LDFLAGS=-L$PWD/src/solaris
  116. </code></pre>
  117. <p>See src/solaris/libstdc++.la for more info on this bug.</p>
  118. <p><strong>Note for HP C++ Tru64 users</strong></p>
  119. <p>To compile invoke configure as follows:</p>
  120. <pre><code>./configure CXXFLAGS="-O -std ansi -ieee -D__USE_STD_IOSTREAM"
  121. </code></pre>
  122. <p>Also, you will need to use gmake instead of make.</p>
  123. <h2>
  124. <a name="c-installation---windows" class="anchor" href="#c-installation---windows"><span class="octicon octicon-link"></span></a>C++ Installation - Windows</h2>
  125. <p>If you are using Microsoft Visual C++, see vsprojects/readme.txt.</p>
  126. <p>If you are using Cygwin or MinGW, follow the Unix installation
  127. instructions, above.</p>
  128. <h2>
  129. <a name="binary-compatibility-warning" class="anchor" href="#binary-compatibility-warning"><span class="octicon octicon-link"></span></a>Binary Compatibility Warning</h2>
  130. <p>Due to the nature of C++, it is unlikely that any two versions of the
  131. Protocol Buffers C++ runtime libraries will have compatible ABIs.
  132. That is, if you linked an executable against an older version of
  133. libprotobuf, it is unlikely to work with a newer version without
  134. re-compiling. This problem, when it occurs, will normally be detected
  135. immediately on startup of your app. Still, you may want to consider
  136. using static linkage. You can configure this package to install
  137. static libraries only using:</p>
  138. <pre><code>./configure --disable-shared
  139. </code></pre>
  140. <h2>
  141. <a name="java-and-python-installation" class="anchor" href="#java-and-python-installation"><span class="octicon octicon-link"></span></a>Java and Python Installation</h2>
  142. <p>The Java and Python runtime libraries for Protocol Buffers are located
  143. in the java and python directories. See the README file in each
  144. directory for more information on how to compile and install them.
  145. Note that both of them require you to first install the Protocol
  146. Buffer compiler (protoc), which is part of the C++ package.</p>
  147. <h2>
  148. <a name="usage" class="anchor" href="#usage"><span class="octicon octicon-link"></span></a>Usage</h2>
  149. <p>The complete documentation for Protocol Buffers is available via the
  150. web at:</p>
  151. <pre><code>https://developers.google.com/protocol-buffers/
  152. </code></pre>
  153. </section>
  154. </div>
  155. <!-- FOOTER -->
  156. <div id="footer_wrap" class="outer">
  157. <footer class="inner">
  158. <p class="copyright">Google Protocol Buffers maintained by <a href="https://github.com/google">google</a></p>
  159. <p>Published with <a href="http://pages.github.com">GitHub Pages</a></p>
  160. </footer>
  161. </div>
  162. </body>
  163. </html>