Including source files from a separate C++ project [message #972738] |
Mon, 05 November 2012 21:36 |
Max Spencer Messages: 1 Registered: November 2012 |
Junior Member |
|
|
I have a project which uses some functions from OpevCV and it compiles into an executable and works fine. Now I want to have a new project which uses some of the functions defined in the first one. I can't get the two to compile and link together.
I have in the relevant files in the new project, I've added the old project to the referenced projects of the new project and in the build settings of the new project, I've added the source folder of the old project as an include (-I gcc option).
I've attached a screenshot of my Eclipse in case it's helpful. The error given by the compiler is at the bottom:
Building target: OtherProject
Invoking: GCC C++ Linker
g++ -o "OtherProject" ./src/foo.o
./src/foo.o: In function `main':
/home/max/opencvjni/OtherProject/Debug/../src/foo.cpp:13: undefined reference to `threshold()'
collect2: ld returned 1 exit status
make: *** [OtherProject] Error 1
Here is the code in those other files in the other tabs of the screenshot:
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_ */
Thank you for looking at my post, if there is no way to do this, or it is just more sensible to do it another way, please don't hesitate to say so.
Regards,
Max
|
|
|
|
Powered by
FUDForum. Page generated in 0.03377 seconds