Mac OS X 10.9.4编译Protobuf-2.4.1问题

2014-08-09 wcdj


(1) 第一步,./configure没问题。

./configure --prefix=/Users/gerryyang/LAMP/protobuf/install/protobuf-2.4.1

(2) 第二步,make,报错如下:

google/protobuf/message.cc:130:60: error: implicit instantiation of undefined template
      'std::__1::basic_istream >'
  return ParseFromZeroCopyStream(&zero_copy_input) && input->eof();
                                                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:109:33: note: 
      template is declared here
    class _LIBCPP_TYPE_VIS_ONLY basic_istream;
                                ^
google/protobuf/message.cc:135:67: error: implicit instantiation of undefined template
      'std::__1::basic_istream >'
  return ParsePartialFromZeroCopyStream(&zero_copy_input) && input->eof();
                                                                  ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:109:33: note: 
      template is declared here
    class _LIBCPP_TYPE_VIS_ONLY basic_istream;
                                ^
google/protobuf/message.cc:175:16: error: implicit instantiation of undefined template
      'std::__1::basic_ostream >'
  return output->good();
               ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:111:33: note: 
      template is declared here
    class _LIBCPP_TYPE_VIS_ONLY basic_ostream;
                                ^
3 errors generated.
make[2]: *** [message.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

根据错误信息,对报错的文件进行如下修改:

protobuf-2.4.1/src/google/protobuf/message.cc,添加#include

Mac OS X 10.9.4编译Protobuf-2.4.1问题_第1张图片

添加后make成功。

(3) 第三步,make install,安装到自定义目录。

gerryyang@mba:protobuf-2.4.1$pwd
/Users/gerryyang/LAMP/protobuf/install/protobuf-2.4.1
gerryyang@mba:protobuf-2.4.1$ls
bin/  include/  lib/
gerryyang@mba:protobuf-2.4.1$du -csh *
12K	bin
864K	include
34M	lib
35M	total
gerryyang@mba:protobuf-2.4.1$cd bin
gerryyang@mba:bin$ls
protoc*
gerryyang@mba:bin$./protoc --help
Usage: ./protoc [OPTION] PROTO_FILES
Parse PROTO_FILES and generate output based on the options given:
  -IPATH, --proto_path=PATH   Specify the directory in which to search for
                              imports.  May be specified multiple times;
                              directories will be searched in order.  If not
                              given, the current working directory is used.
  --version                   Show version info and exit.
  -h, --help                  Show this text and exit.
  --encode=MESSAGE_TYPE       Read a text-format message of the given type
                              from standard input and write it in binary
                              to standard output.  The message type must
                              be defined in PROTO_FILES or their imports.
  --decode=MESSAGE_TYPE       Read a binary message of the given type from
                              standard input and write it in text format
                              to standard output.  The message type must
                              be defined in PROTO_FILES or their imports.
  --decode_raw                Read an arbitrary protocol message from
                              standard input and write the raw tag/value
                              pairs in text format to standard output.  No
                              PROTO_FILES should be given when using this
                              flag.
  -oFILE,                     Writes a FileDescriptorSet (a protocol buffer,
    --descriptor_set_out=FILE defined in descriptor.proto) containing all of
                              the input files to FILE.
  --include_imports           When using --descriptor_set_out, also include
                              all dependencies of the input files in the
                              set, so that the set is self-contained.
  --error_format=FORMAT       Set the format in which to print errors.
                              FORMAT may be 'gcc' (the default) or 'msvs'
                              (Microsoft Visual Studio format).
  --plugin=EXECUTABLE         Specifies a plugin executable to use.
                              Normally, protoc searches the PATH for
                              plugins, but you may specify additional
                              executables not in the path using this flag.
                              Additionally, EXECUTABLE may be of the form
                              NAME=PATH, in which case the given plugin name
                              is mapped to the given executable even if
                              the executable's own name differs.
  --cpp_out=OUT_DIR           Generate C++ header and source.
  --java_out=OUT_DIR          Generate Java source file.
  --python_out=OUT_DIR        Generate Python source file. 


google对于此问题提供的解决方法:

https://code.google.com/p/protobuf/issues/detail?id=455

Here is a patch to fix the bug:


--- message.cc	2013-01-21 13:35:40.000000000 -0500
+++ message copy.cc	2013-01-21 13:34:44.000000000 -0500
@@ -49,6 +49,8 @@
 #include 
 #include 
 
+#include 
+
 namespace google {
 namespace protobuf {




你可能感兴趣的:(Mac OS X 10.9.4编译Protobuf-2.4.1问题)