protobuf使用brew安装但在构建过程中找不到

时间:2015-05-13 04:02:43

标签: makefile protocol-buffers homebrew caffe matcaffe

背景

昨天我构建了Caffe并且对其依赖项没有任何问题。

今天由于找不到protobuf依赖项,我在构建Caffe Matlab包装器时遇到了问题。所以我重建了Caffe:make clean后跟一个make all,希望能解决这个问题。

现在Caffe构建正在抱怨protobuf依赖。

错误输出在此问题的底部给出。

在原始(成功)构建和失败构建之间,我需要pip install protobuf允许Caffe python包装器导入protobuf,因为python抱怨无法找到protobuf包。这是在失败的Caffe重建之前唯一涉及protobuf的“变化”。

我曾尝试使用brew重新安装protobuf,但这没有帮助。

因此,与protobuf相关的事件的年表基本如下:

1. protobuf installed from source using brew:
     brew install --build-from-source --with-python --fresh -vd protobuf
2. caffe built successfully  
3. caffe python wrappers failed to build -- protobuf not found
4. pip install protobuf
5. caffe python wrappers built successfully
6. caffe matlab wrappers failed to build -- protobuf not found
7. tried to rebuild caffe -- failed -- protobuf not found
8. reinstalled protobuf from source using brew
9. tried again to rebuild caffe -- failed -- protobuf not found

每当找不到protobuf时,brew list --versions显示安装了protobuf(2.6.1)。

问题

有人可以解释为什么在明确安装protobuf时没有找到它?

最令人困惑的是它最初被发现(在原始的,成功的构建期间)并且现在尽管采用了相同的方法但仍未被发现。

以下是错误输出:

$ make clean
$ make all -j8
[... truncated ...]
CXX examples/mnist/convert_mnist_data.cpp
CXX examples/siamese/convert_mnist_siamese_data.cpp
CXX .build_release/src/caffe/proto/caffe.pb.cc
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so
clang: warning: argument unused during compilation: '-pthread'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_conv_layer.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_pooling_layer.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_relu_layer.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_sigmoid_layer.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_softmax_layer.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_tanh_layer.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn.o) has no symbols
Undefined symbols for architecture x86_64:
  "google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned char*)", referenced from:
      caffe::Datum::SerializeWithCachedSizesToArray(unsigned char*) const in caffe.pb.o
      caffe::FillerParameter::SerializeWithCachedSizesToArray(unsigned char*) const in caffe.pb.o
      caffe::NetParameter::SerializeWithCachedSizesToArray(unsigned char*) const in caffe.pb.o
      caffe::SolverParameter::SerializeWithCachedSizesToArray(unsigned char*) const in caffe.pb.o
      caffe::SolverState::SerializeWithCachedSizesToArray(unsigned char*) const in caffe.pb.o
      caffe::NetState::SerializeWithCachedSizesToArray(unsigned char*) const in caffe.pb.o
      caffe::NetStateRule::SerializeWithCachedSizesToArray(unsigned char*) const in caffe.pb.o
      ...
  "google::protobuf::internal::empty_string_", referenced from:
      caffe::Datum::SharedCtor() in caffe.pb.o
      caffe::Datum::MergeFrom(caffe::Datum const&) in caffe.pb.o
      caffe::Datum::~Datum() in caffe.pb.o
      caffe::Datum::SharedDtor() in caffe.pb.o
      caffe::Datum::Clear() in caffe.pb.o
      caffe::Datum::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in caffe.pb.o
      caffe::NetParameter::SharedCtor() in caffe.pb.o
      ...
  "google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, google::protobuf::io::CodedOutputStream*)", referenced from:
      caffe::Datum::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o
  "google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, google::protobuf::io::CodedOutputStream*)", referenced from:
      caffe::FillerParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o
      caffe::NetParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o
      caffe::SolverParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o
      caffe::SolverState::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o
      caffe::ParamSpec::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o
      caffe::LayerParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o
      caffe::TransformationParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o
      ...
  "google::protobuf::internal::InitEmptyString()", referenced from:
      caffe::Datum::SharedCtor() in caffe.pb.o
      caffe::FillerParameter::SharedCtor() in caffe.pb.o
      caffe::NetParameter::SharedCtor() in caffe.pb.o
      caffe::SolverParameter::SharedCtor() in caffe.pb.o
      caffe::SolverState::SharedCtor() in caffe.pb.o
      caffe::NetState::SharedCtor() in caffe.pb.o
      caffe::NetStateRule::SharedCtor() in caffe.pb.o
      ...
  "google::protobuf::internal::empty_string_once_init_", referenced from:
      caffe::Datum::SharedCtor() in caffe.pb.o
      caffe::FillerParameter::SharedCtor() in caffe.pb.o
      caffe::NetParameter::SharedCtor() in caffe.pb.o
      caffe::SolverParameter::SharedCtor() in caffe.pb.o
      caffe::SolverState::SharedCtor() in caffe.pb.o
      caffe::NetState::SharedCtor() in caffe.pb.o
      caffe::NetStateRule::SharedCtor() in caffe.pb.o
      ...
  "google::protobuf::io::CodedInputStream::BytesUntilTotalBytesLimit() const", referenced from:
      bool google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<float, (google::protobuf::internal::WireFormatLite::FieldType)2>(google::protobuf::io::CodedInputStream*, google::protobuf::RepeatedField<float>*) in caffe.pb.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [.build_release/lib/libcaffe.so] Error 1

1 个答案:

答案 0 :(得分:0)

你是否从源代码构建了protobuf?由于使用不同版本的libc ++编译protobuf和我的项目,我遇到了类似的问题。

我通过将C ++ 11添加到CXXFLAGS来解决它。