编译caffe分类时出错

时间:2016-03-05 20:13:44

标签: c++ macos osx-yosemite deep-learning caffe

我尝试使用以下命令在OS X 10.10.5上编译caffe分类示例:

g++ -ggdb `pkg-config --cflags --libs opencv` -I /Users/SullyChen/caffe/include -I /usr/local/cuda/include -I /usr/local/Cellar/openblas/0.2.15/include -lboost_system -lglog -lprotobuf classification.cpp -o classification

但是我收到以下错误:

Undefined symbols for architecture x86_64:
  "caffe::ReadProtoFromBinaryFile(char const*, google::protobuf::Message*)", referenced from:
      caffe::ReadProtoFromBinaryFileOrDie(char const*, google::protobuf::Message*) in classification-ff6167.o
  "caffe::Net<float>::CopyTrainedLayersFrom(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      Classifier::Classifier(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in classification-ff6167.o
  "caffe::Net<float>::Forward(float*)", referenced from:
      Classifier::Predict(cv::Mat const&) in classification-ff6167.o
  "caffe::Net<float>::Reshape()", referenced from:
      Classifier::Predict(cv::Mat const&) in classification-ff6167.o
  "caffe::Net<float>::Net(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, caffe::Phase, caffe::Net<float> const*)", referenced from:
      Classifier::Classifier(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in classification-ff6167.o
  "caffe::Blob<float>::mutable_cpu_data()", referenced from:
      Classifier::SetMean(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in classification-ff6167.o
      Classifier::WrapInputLayer(std::__1::vector<cv::Mat, std::__1::allocator<cv::Mat> >*) in classification-ff6167.o
  "caffe::Blob<float>::Reshape(int, int, int, int)", referenced from:
      Classifier::Predict(cv::Mat const&) in classification-ff6167.o
  "caffe::Blob<float>::FromProto(caffe::BlobProto const&, bool)", referenced from:
      Classifier::SetMean(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in classification-ff6167.o
  "caffe::Caffe::Get()", referenced from:
      caffe::Caffe::set_mode(caffe::Caffe::Brew) in classification-ff6167.o
  "caffe::BlobProto::BlobProto()", referenced from:
      Classifier::SetMean(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in classification-ff6167.o
  "caffe::BlobProto::~BlobProto()", referenced from:
      Classifier::SetMean(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in classification-ff6167.o
  "caffe::Blob<float>::cpu_data() const", referenced from:
      Classifier::Predict(cv::Mat const&) in classification-ff6167.o
      Classifier::Preprocess(cv::Mat const&, std::__1::vector<cv::Mat, std::__1::allocator<cv::Mat> >*) in classification-ff6167.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

关于问题是什么的任何想法?

1 个答案:

答案 0 :(得分:0)

哦,天哪,我忘了把Caffe联系起来......那问题就解决了。

编辑:这是我用过的命令,如果有人需要它

g++ -ggdb `pkg-config --cflags --libs opencv` -I /Users/SullyChen/caffe/include -I /usr/local/cuda/include -I /usr/local/Cellar/openblas/0.2.15/include -lboost_system -lglog -lprotobuf -L /Users/SullyChen/caffe/.build_release/lib -lcaffe classification.cpp -o classification