1fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleProtocol Buffers - Google's data interchange format
2fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleCopyright 2008 Google Inc.
3fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savillehttp://code.google.com/apis/protocolbuffers/
4fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
5fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleC++ Installation - Unix
6fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville=======================
7fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
8fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleTo build and install the C++ Protocol Buffer runtime and the Protocol
9fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleBuffer compiler (protoc) execute the following:
10fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
11fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  $ ./configure
12fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  $ make
13fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  $ make check
14fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  $ make install
15fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
16fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleIf "make check" fails, you can still install, but it is likely that
17fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savillesome features of this library will not work correctly on your system.
18fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleProceed at your own risk.
19fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
20fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville"make install" may require superuser privileges.
21fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
22fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleFor advanced usage information on configure and make, see INSTALL.txt.
23fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
24fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville** Hint on install location **
25fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
26fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  By default, the package will be installed to /usr/local.  However,
27fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH.
28fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  You can add it, but it may be easier to just install to /usr
29fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  instead.  To do this, invoke configure as follows:
30fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
31fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville    ./configure --prefix=/usr
32fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
33fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  If you already built the package with a different prefix, make sure
34fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  to run "make clean" before building again.
35fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
36fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville** Compiling dependent packages **
37fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
38fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  To compile a package that uses Protocol Buffers, you need to pass
39fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  various flags to your compiler and linker.  As of version 2.2.0,
40fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  Protocol Buffers integrates with pkg-config to manage this.  If you
41fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  have pkg-config installed, then you can invoke it to get a list of
42fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  flags like so:
43fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
44fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville    pkg-config --cflags protobuf         # print compiler flags
45fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville    pkg-config --libs protobuf           # print linker flags
46fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville    pkg-config --cflags --libs protobuf  # print both
47fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
48fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  For example:
49fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
50fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville    c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`
51fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
52fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  Note that packages written prior to the 2.2.0 release of Protocol
53fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  Buffers may not yet integrate with pkg-config to get flags, and may
54fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  not pass the correct set of flags to correctly link against
55fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  libprotobuf.  If the package in question uses autoconf, you can
56fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  often fix the problem by invoking its configure script like:
57fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
58fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville    configure CXXFLAGS="$(pkg-config --cflags protobuf)" \
59fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville              LIBS="$(pkg-config --libs protobuf)"
60fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
61fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  This will force it to use the correct flags.
62fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
63fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  If you are writing an autoconf-based package that uses Protocol
64fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  Buffers, you should probably use the PKG_CHECK_MODULES macro in your
65fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  configure script like:
66fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
67fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville    PKG_CHECK_MODULES([protobuf], [protobuf])
68fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
69fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  See the pkg-config man page for more info.
70fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
71fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  If you only want protobuf-lite, substitute "protobuf-lite" in place
72fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  of "protobuf" in these examples.
73fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
74fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville** Note for cross-compiling **
75fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
76fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  The makefiles normally invoke the protoc executable that they just
77fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  built in order to build tests.  When cross-compiling, the protoc
78fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  executable may not be executable on the host machine.  In this case,
79fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  you must build a copy of protoc for the host machine first, then use
80fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  the --with-protoc option to tell configure to use it instead.  For
81fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  example:
82fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
83fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville    ./configure --with-protoc=protoc
84fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
85fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  This will use the installed protoc (found in your $PATH) instead of
86fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  trying to execute the one built during the build process.  You can
87fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  also use an executable that hasn't been installed.  For example, if
88fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  you built the protobuf package for your host machine in ../host,
89fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  you might do:
90fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
91fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville    ./configure --with-protoc=../host/src/protoc
92fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
93fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  Either way, you must make sure that the protoc executable you use
94fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  has the same version as the protobuf source code you are trying to
95fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  use it with.
96fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
97fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville** Note for Solaris users **
98fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
99fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  Solaris 10 x86 has a bug that will make linking fail, complaining
100fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  about libstdc++.la being invalid.  We have included a work-around
101fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  in this package.  To use the work-around, run configure as follows:
102fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
103fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville    ./configure LDFLAGS=-L$PWD/src/solaris
104fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
105fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  See src/solaris/libstdc++.la for more info on this bug.
106fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
107fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville** Note for HP C++ Tru64 users **
108fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
109fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  To compile invoke configure as follows:
110fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
111fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville    ./configure CXXFLAGS="-O -std ansi -ieee -D__USE_STD_IOSTREAM"
112fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
113fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  Also, you will need to use gmake instead of make.
114fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
115fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleC++ Installation - Windows
116fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville==========================
117fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
118fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleIf you are using Micosoft Visual C++, see vsprojects/readme.txt.
119fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
120fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleIf you are using Cygwin or MinGW, follow the Unix installation
121fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savilleinstructions, above.
122fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
123fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleBinary Compatibility Warning
124fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville============================
125fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
126fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleDue to the nature of C++, it is unlikely that any two versions of the
127fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleProtocol Buffers C++ runtime libraries will have compatible ABIs.
128fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleThat is, if you linked an executable against an older version of
129fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savillelibprotobuf, it is unlikely to work with a newer version without
130fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savillere-compiling.  This problem, when it occurs, will normally be detected
131fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savilleimmediately on startup of your app.  Still, you may want to consider
132fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savilleusing static linkage.  You can configure this package to install
133fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savillestatic libraries only using:
134fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
135fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  ./configure --disable-shared
136fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
137fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleJava and Python Installation
138fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville============================
139fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
140fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleThe Java and Python runtime libraries for Protocol Buffers are located
141fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savillein the java and python directories.  See the README file in each
142fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savilledirectory for more information on how to compile and install them.
143fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleNote that both of them require you to first install the Protocol
144fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleBuffer compiler (protoc), which is part of the C++ package.
145fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
146fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleUsage
147fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville=====
148fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
149fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleThe complete documentation for Protocol Buffers is available via the
150fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savilleweb at:
151fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville
152fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville  http://code.google.com/apis/protocolbuffers/
153