在原本能正常使用的caffe中修改代码后重新编译,会产生如下错误:
CXX/LD -o .build_release/tools/caffe.bin
 .build_release/tools/caffe.o: In function `test()':
 caffe.cpp:(.text+0x15b3): undefined reference to `caffe::Net<float>::Net(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, caffe::Phase, int, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const*, caffe::Net<float> const*)'
 .build_release/tools/caffe.o: In function `train()':
 caffe.cpp:(.text+0x30a7): undefined reference to `caffe::P2PSync<float>::P2PSync(boost::shared_ptr<caffe::Solver<float> >, caffe::P2PSync<float>*, caffe::SolverParameter const&)'
 caffe.cpp:(.text+0x30cc): undefined reference to `caffe::P2PSync<float>::Run(std::vector<int, std::allocator<int> > const&)'
 caffe.cpp:(.text+0x30d4): undefined reference to `caffe::P2PSync<float>::~P2PSync()'
 caffe.cpp:(.text+0x45ad): undefined reference to `caffe::P2PSync<float>::~P2PSync()'
 .build_release/tools/caffe.o: In function `time()':
 caffe.cpp:(.text+0x4a43): undefined reference to `caffe::Net<float>::Net(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, caffe::Phase, int, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const*, caffe::Net<float> const*)'
 caffe.cpp:(.text+0x4dc2): undefined reference to `caffe::Layer<float>::Lock()'
 caffe.cpp:(.text+0x4eba): undefined reference to `caffe::Layer<float>::Unlock()'
 collect2: error: ld returned 1 exit status
 Makefile:622: recipe for target '.build_release/tools/caffe.bin' failed
 make: *** [.build_release/tools/caffe.bin] Error 1
  
解决方法:
在自己的/usr/local/路径下使用find命令查看是否有libcaffe相关的so文件,如果有,则把它们删除之后再次重新编译caffe就能解决上述问题:例如我的在/usr/local/lib/路径下,则执行:
sudo rm libcaffe.*