Home | History | Annotate | only in /external/protobuf/src
Up to higher level directory
NameDateSize
google/21-Aug-2018
Makefile.am21-Aug-201848.9K
README.md21-Aug-20187K
solaris/21-Aug-2018

README.md

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