Open forever3000 opened 7 years ago
The culprit seems to be -I/home/vu/Desktop/Projects/caffe2
, which includes too broadly. Just removing that should resolve these build errors.
Also, you probably need to add -Iinclude
, which includes headers from the caffe2_cpp_tutorial project. See the build alternatives section for more info.
I tried to rebuild one Caffe2 C++ example as this link : https://github.com/leonardvandriel/caffe2_cpp_tutorial
But with simple g++ command as below:
g++ pretrain.cc -I/home/vu/Desktop/Projects/caffe2 -I/home/vu/Desktop/Projects/caffe2/build -I/home/vu/Desktop/Projects/caffe2/third_party/eigen -lCaffe2_CPU -lprotobuf -lglog -lgflags -pthread --std=c++11
pkg-config --cflags --libs opencv-L/home/vu/Desktop/Projects/caffe2/build/caffe2
then got this error:/tmp/ccZEKrOW.o: In function
caffe2::(anonymous namespace)::Caffe2FlagParser_init_net::Caffe2FlagParser_init_net(std::string const&)': pretrain.cc:(.text+0x12a): undefined reference tobool caffe2::Caffe2FlagParser::Parse<std::string>(std::string const&, std::string*)' /tmp/ccZEKrOW.o: In function
caffe2::(anonymous namespace)::Caffe2FlagParser_predict_net::Caffe2FlagParser_predict_net(std::string const&)': pretrain.cc:(.text+0x166): undefined reference tobool caffe2::Caffe2FlagParser::Parse<std::string>(std::string const&, std::string*)' /tmp/ccZEKrOW.o: In function
caffe2::(anonymous namespace)::Caffe2FlagParser_image_file::Caffe2FlagParser_image_file(std::string const&)': pretrain.cc:(.text+0x1a2): undefined reference tobool caffe2::Caffe2FlagParser::Parse<std::string>(std::string const&, std::string*)' /tmp/ccZEKrOW.o: In function
caffe2::(anonymous namespace)::Caffe2FlagParser_size_to_fit::Caffe2FlagParser_size_to_fit(std::string const&)': pretrain.cc:(.text+0x1de): undefined reference tobool caffe2::Caffe2FlagParser::Parse<int>(std::string const&, int*)' /tmp/ccZEKrOW.o: In function
__static_initialization_and_destruction_0(int, int)': pretrain.cc:(.text+0x144f): undefined reference tocaffe2::Caffe2FlagsRegistry()' pretrain.cc:(.text+0x154a): undefined reference to
caffe2::Caffe2FlagsRegistry()' pretrain.cc:(.text+0x1645): undefined reference tocaffe2::Caffe2FlagsRegistry()' pretrain.cc:(.text+0x16fe): undefined reference to
caffe2::Caffe2FlagsRegistry()' /tmp/ccZEKrOW.o: In functioncaffe2::CPUContext::New(unsigned long)': pretrain.cc:(.text._ZN6caffe210CPUContext3NewEm[_ZN6caffe210CPUContext3NewEm]+0x32): undefined reference to
caffe2::FLAGS_caffe2_report_cpu_memory_usage' /tmp/ccZEKrOW.o: In functionvoid caffe2::Tensor<caffe2::CPUContext>::Resize<std::vector<long, std::allocator<long> > >(std::vector<long, std::allocator<long> >)': pretrain.cc:(.text._ZN6caffe26TensorINS_10CPUContextEE6ResizeIISt6vectorIlSaIlEEEEEvDpT_[_ZN6caffe26TensorINS_10CPUContextEE6ResizeIISt6vectorIlSaIlEEEEEvDpT_]+0x92): undefined reference to
caffe2::FLAGS_caffe2_keep_on_shrink' pretrain.cc:(.text._ZN6caffe26TensorINS10CPUContextEE6ResizeIISt6vectorIlSaIlEEEEEvDpT[_ZN6caffe26TensorINS10CPUContextEE6ResizeIISt6vectorIlSaIlEEEEEvDpT]+0xaf): undefined reference tocaffe2::FLAGS_caffe2_max_keep_on_shrink_memory' collect2: error: ld returned 1 exit status
Anybody is facing same problem. May I need to rebuild caffe2 to support above APIs. Thanks