c++ - 对 cv::inpaint 的 undefined reference - 错误 1

标签 c++ linux eclipse image-processing opencv

我需要帮助。 几个月前,我在 Windows 上的 Visual Studio 中编写了这段 C++ 代码。我从该代码制作 .exe 文件,一切正常,就像这样。这是用于图像处理的简单代码。现在我尝试在 Linux 上的 Eclipse 中做同样的事情,以便我可以将可执行文件放在 Linux Web 服务器上。但是我有这个错误:

In function `main':
main.cpp:(.text.startup+0x317): undefined reference to `cv::inpaint(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, double, int)'
collect2: ld returned 1 exit status
make: *** [inpaint] Error 1

我使用 OpencCV 2.4.1 库。这是源代码:

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/photo/photo.hpp"
#include <iostream>


using namespace cv;
using namespace std;
Mat img, img0, maska;
int main( int argc, char** argv )
{

...
   }
Mat inpainted;
inpaint(img0, img, inpainted, 2, CV_INPAINT_NS);
char imeobr[256] = "images/img-uploads/finish";
strcat( imeobr, argv[1] );
strcat( imeobr, ".jpg" );
imwrite(imeobr, inpainted);
return 0;
}

我认为这是输入源的问题,因为它不是输入图像的固定名称。但是,我需要为每个应用程序用户动态更改输入源。 请帮助人们。我能做什么?

最佳答案

当您忽略链接库时会发生 undefined reference 错误:

在您的项目的首选项中:

C/C++ Build -> GCC C++ Linker -> Libraries

你有没有在 Libraries(-l) 中输入 libopencv_imgproc 库?

更新

为了测试,我创建了我的程序:

#include <opencv/highgui.h>
#include <opencv/cv.h>

using namespace cv;

int main(int argc, char* argv[]) {
  Mat img, img0;
  Mat inpainted;
  inpaint(img0, img, inpainted, 2, CV_INPAINT_NS);
}

在我链接的库中:

opencv_imgproc 
opencv_highgui
opencv_core

一切正常..试一试然后告诉我!

关于c++ - 对 cv::inpaint 的 undefined reference - 错误 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13741143/

相关文章:

linux - 不允许 mknod 操作

java - 将使用 ant 构建的 Java eclipse 项目迁移到 Gradle

c++ - 运行时错误:将 .push_back() 与 std::vector 一起使用时出现访问冲突?

c++ - 如何将这些自定义对象列表的时间复杂度从 O(n) 降低到 O(1)?

linux - context_switch 和系统调用虚拟化

python - shell脚本: compile and execute a python via shell script

java - 在中央找不到 Artifact javax.sql :jdbc-stdext:jar:2. 0 (https ://repo. maven.apache.org/maven2)

eclipse - 在 Eclipse 中删除 release 文件夹后如何重建?

c++ - c/c++中用函数指针模仿OO,如何存储?

c++ - Visual C++ 错误 LNK2019