在Ubuntu 20.04中安装opencv

时间:2020-06-16 12:15:18

标签: opencv ubuntu

我正在尝试重新安装opencv,但是在下载并安装后,当我运行pkg-config命令时,它说找不到opencv.pc文件以及创建自己的文件时。

prefix=/usr

exec_prefix=${prefix}

includedir=${prefix}/include

libdir=${exec_prefix}/lib

Name: opencv

Description: The opencv library

Version: 2.x.x

Cflags: -I${includedir}/opencv -I${includedir}/opencv4

Libs: -L${libdir} -lopencv_calib3d -lopencv_imgproc 

现在,当我尝试运行代码时,出现以下错误:

/usr/bin/ld: /tmp/ccbr63zc.o: in function `main':
main2.cpp:(.text+0x63): undefined reference to `cv::samples::findFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool)'
/usr/bin/ld: main2.cpp:(.text+0x99): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/usr/bin/ld: main2.cpp:(.text+0x151): undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
/usr/bin/ld: main2.cpp:(.text+0x188): undefined reference to `cv::waitKey(int)'
/usr/bin/ld: main2.cpp:(.text+0x22d): undefined reference to `cv::imwrite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
/usr/bin/ld: /tmp/ccbr63zc.o: in function `cv::Mat::~Mat()':
main2.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x3d): undefined reference to `cv::fastFree(void*)'
/usr/bin/ld: /tmp/ccbr63zc.o: in function `cv::Mat::release()':
main2.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4f): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status

0 个答案:

没有答案