0

背景

昨天我构建了Caffe,它的依赖关系没有问题。

今天,由于找不到 protobuf 依赖项,我在构建 Caffe Matlab 包装器时遇到了问题。所以我重建了 Caffe:make clean后跟 a 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
4

1 回答 1

0

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

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

于 2015-10-29T09:09:13.580 回答