33
33
If you already built the package with a different prefix, make sure
34
34
to run "make clean" before building again.
36
** Compiling dependent packages **
38
To compile a package that uses Protocol Buffers, you need to pass
39
various flags to your compiler and linker. As of version 2.2.0,
40
Protocol Buffers integrates with pkg-config to manage this. If you
41
have pkg-config installed, then you can invoke it to get a list of
44
pkg-config --cflags protobuf # print compiler flags
45
pkg-config --libs protobuf # print linker flags
46
pkg-config --cflags --libs protobuf # print both
50
c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`
52
Note that packages written prior to the 2.2.0 release of Protocol
53
Buffers may not yet integrate with pkg-config to get flags, and may
54
not pass the correct set of flags to correctly link against
55
libprotobuf. If the package in question uses autoconf, you can
56
often fix the problem by invoking its configure script like:
58
configure CXXFLAGS="$(pkg-config --cflags protobuf)" \
59
LIBS="$(pkg-config --libs protobuf)"
61
This will force it to use the correct flags.
63
If you are writing an autoconf-based package that uses Protocol
64
Buffers, you should probably use the PKG_CHECK_MODULES macro in your
65
configure script like:
67
PKG_CHECK_MODULES([protobuf], [protobuf])
69
See the pkg-config man page for more info.
71
If you only want protobuf-lite, substitute "protobuf-lite" in place
72
of "protobuf" in these examples.
36
74
** Note for cross-compiling **
38
76
The makefiles normally invoke the protoc executable that they just