【发布时间】:2016-07-06 01:14:31
【问题描述】:
我已经为代码块安装了 Opencv,并且程序在代码块中运行良好。但是当我尝试从命令提示符运行程序时,我得到一个错误fatal error:opencv2/opencv.hpp No such file or directory compilation terminated
所以我将命令运行为
g++ -IC:\opencv\build\include -o main.exe main.cpp
我得到许多未定义的引用错误。我什至尝试将库链接为
g++ -IC:\opencv\build\include -LC:\opencv\build\x86\mingw\lib -o main.exe main.cpp
我仍然遇到同样的错误。我使用的是 Opencv 2.4.5。我没有使用 -l 选项,因为有很多库,我不知道如何一次链接所有这些库(目录)。
这是编译输出。
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x6d): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xb7): undefined reference to `cv::Mat::convertTo(cv::_OutputArray const&, int, double, double) const'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x152): undefined reference to `cv::Mat::zeros(int, int, int)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x322): undefined reference to `cv::noArray()'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x384): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x3bd): undefined reference to `cv::meanStdDev(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::_InputArray const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x5c7): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x5ea): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x645): undefined reference to `cv::resize(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, double, double, int)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x665): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x685): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x6d6): undefined reference to `cv::threshold(cv::_InputArray const&, cv::_OutputArray const&, double, double, int)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x705): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x752): undefined reference to `cv::Mat::convertTo(cv::_OutputArray const&, int, double, double) const'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x775): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x7c2): undefined reference to `cv::Mat::convertTo(cv::_OutputArray const&, int, double, double) const'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x7e5): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x808): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x828): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x86e): undefined reference to `cv::inpaint(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, double, int)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x89e): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x8be): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x910): undefined reference to `cv::resize(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, double, double, int)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x92a): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x971): undefined reference to `cv::Mat::convertTo(cv::_OutputArray const&, int, double, double) const'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xc68): undefined reference to `cv::namedWindow(std::string const&, int)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xcee): undefined reference to `cv::imread(std::string const&, int)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xd3f): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xd8c): undefined reference to `cv::Mat::convertTo(cv::_OutputArray const&, int, double, double) const'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xe05): undefined reference to `cv::operator-(cv::Scalar_<double> const&, cv::Mat const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xe6b): undefined reference to `cv::operator+(cv::Mat const&, cv::Mat const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xebb): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xede): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xf2f): undefined reference to `cv::threshold(cv::_InputArray const&, cv::_OutputArray const&, double, double, int)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xf74): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xf97): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0xff2): undefined reference to `cv::resize(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, double, double, int)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x103d): undefined reference to `cv::operator*(cv::Mat const&, double)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x105d): undefined reference to `cv::_InputArray::_InputArray(cv::MatExpr const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x10b8): undefined reference to `cv::imwrite(std::string const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text+0x1110): undefined reference to `cv::waitKey(int)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x2d): undefined reference to `cv::fastFree(void*)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text$_ZN2cv3MataSERKS0_[__ZN2cv3MataSERKS0_]+0x102): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text$_ZN2cv3Mat7releaseEv[__ZN2cv3Mat7releaseEv]+0x3e): undefined reference to `cv::Mat::deallocate()'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text$_ZNK2cv3MatclENS_5RangeES1_[__ZNK2cv3MatclENS_5RangeES1_]+0x23): undefined reference to `cv::Mat::Mat(cv::Mat const&, cv::Range const&, cv::Range const&)'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text$_ZN2cv12_OutputArrayC1IdLi4ELi1EEERNS_4MatxIT_XT0_EXT1_EEE[__ZN2cv12_OutputArrayC1IdLi4ELi1EEERNS_4MatxIT_XT0_EXT1_EEE]+0x21): undefined reference to `vtable for cv::_OutputArray'
C:\Users\HP\AppData\Local\Temp\ccraot3b.o:main.cpp:(.text$_ZN2cv11_InputArrayC2IdLi4ELi1EEERKNS_4MatxIT_XT0_EXT1_EEE[__ZN2cv11_InputArrayC2IdLi4ELi1EEERKNS_4MatxIT_XT0_EXT1_EEE]+0xe): undefined reference to `vtable for cv::_InputArray'
collect2.exe: error: ld returned 1 exit status
【问题讨论】:
-
请将编译输出添加到问题中!
标签: c++ opencv gcc cmd undefined-reference