解决错误undefined reference to `cv::imread(cv::String const&, int)'

今天在github上面发现了如下可生成语义分割的label工具,克隆源码下来编译的时候出错了


git clone https://github.com/XingangPan/seg_label_generate.git

cd seg_label_generate

make

错误如下:


build/src/seg_label_generator.o: In function `SegLabelGenerator::showLabels(std::__cxx11::basic_string, std::allocator> const&, int, int)':seg_label_generator.cpp:(.text+0x2150): undefined reference to `cv::imread(cv::String const&, int)'seg_label_generator.cpp:(.text+0x2196): undefined reference to `cv::imread(cv::String const&, int)'seg_label_generator.cpp:(.text+0x23e3): undefined reference to `cv::line(cv::_InputOutputArray const&, cv::Point_, cv::Point_, cv::Scalar_const&, int, int, int)'seg_label_generator.cpp:(.text+0x2596): undefined reference to `cv::circle(cv::_InputOutputArray const&, cv::Point_, int, cv::Scalar_const&, int, int, int)'seg_label_generator.cpp:(.text+0x26e0): undefined reference to `cv::circle(cv::_InputOutputArray const&, cv::Point_, int, cv::Scalar_const&, int, int, int)'seg_label_generator.cpp:(.text+0x2a82): undefined reference to `cv::line(cv::_InputOutputArray const&, cv::Point_, cv::Point_, cv::Scalar_const&, int, int, int)'seg_label_generator.cpp:(.text+0x2bc0): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'build/src/seg_label_generator.o: In function `SegLabelGenerator::outputimLabels(std::__cxx11::basic_string, std::allocator> const&, std::__cxx11::basic_string, std::allocator> const&, int, bool)':seg_label_generator.cpp:(.text+0x3335): undefined reference to `cv::line(cv::_InputOutputArray const&, cv::Point_, cv::Point_, cv::Scalar_const&, int, int, int)'seg_label_generator.cpp:(.text+0x3413): undefined reference to `cv::line(cv::_InputOutputArray const&, cv::Point_, cv::Point_, cv::Scalar_const&, int, int, int)'seg_label_generator.cpp:(.text+0x3809): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector> const&)'build/src/seg_label_generator.o: In function `cv::String::~String()':seg_label_generator.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'build/src/seg_label_generator.o: In function `cv::String::String(std::__cxx11::basic_string, std::allocator > const&)':

seg_label_generator.cpp:(.text._ZN2cv6StringC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN2cv6StringC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x70): undefined reference to `cv::String::allocate(unsigned long)'

build/src/main.o: In function `SegLabelGenerator::SegLabelGenerator()':

main.cpp:(.text._ZN17SegLabelGeneratorC2Ev[_ZN17SegLabelGeneratorC5Ev]+0x1c1): undefined reference to `cv::namedWindow(cv::String const&, int)'

collect2: error: ld returned 1 exit status

Makefile:44: recipe for target 'seg_label_generate' failed

make: *** [seg_label_generate] Error 1

  • 解决的方法:

修改Makefile文件


CXXFLAGS := -std=C++11 -fopenmp `pkg-config --cflag opencv`

LIBS=`pkg-config --libs opencv`

你可能感兴趣的:(解决错误undefined reference to `cv::imread(cv::String const&, int)')