【发布时间】:2012-10-25 19:22:42
【问题描述】:
我在 Eclipse CDT 中有一个 C++ 项目,它使用 OpevCV 中的一些函数,它编译成可执行文件并且工作正常。现在我想要一个新的 C++ 项目,它使用第一个中定义的一些函数。我无法将两者编译并链接在一起。
我在新项目的相关文件中有#include "...",我已经将旧项目添加到新项目的引用项目中,并且在新项目的构建设置中,我已经添加了源文件夹旧项目作为包含(-I gcc 选项)。
我附上了我的 Eclipse 的屏幕截图,以防有用:
编译器给出的错误是:
构建目标:OtherProject
调用:GCC C++ 链接器
g++ -o "OtherProject" ./src/foo.o
./src/foo.o:在函数“main”中:
/home/max/opencvjni/OtherProject/Debug/../src/foo.cpp:13:未定义对阈值()的引用'
collect2: ld 返回 1 个退出状态
make: *** [OtherProject] 错误 1
这是屏幕截图其他选项卡中其他文件中的代码:
Threshold.cpp
#include <cv.h>
#include <highgui.h>
#include "Threshold.h"
using namespace cv;
int threshold(void) {
Mat img = imread("/home/max/opencvjni/monalisa.jpg", 0);
threshold(img, img, 127, 255, THRESH_BINARY);
imwrite("/home/max/opencvjni/monathresh.jpg", img);
return 0;
}
int main(void) {
threshold();
return 0;
}
Threshold.h
#ifndef THRESHOLD_H_
#define THRESHOLD_H_
int threshold(void);
#endif /* THRESHOLD_H_ */[/code]
- Eclipse 版本:3.7.2
- CDT 版本:8.0.2.201202111925
- 操作系统:Ubuntu 12.04
感谢您查看我的帖子,如果没有办法这样做,或者换一种方式这样做更明智,请不要犹豫。
问候
【问题讨论】:
标签: c++ eclipse eclipse-cdt