0
votes

I have been coding in python before and included the library of openCV without any problem. Now, I want to code in C++ so I downloaded eclipse and openCV libraries and included their path in the includes from eclipse ..

I have simple example of openCV and I am trying to run it, but I get this error -->

**** Build of configuration Debug for project Example ****

make all Building file: ../Test.cpp Invoking: GCC C++ Compiler g++ -I/usr/local/include/opencv -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Test.d" -MT"Test.d" -o "Test.o" "../Test.cpp" Finished building: ../Test.cpp

Building target: Example Invoking: GCC C++ Linker g++ -o "Example" ./Test.o
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../crt1.o: In function _start': (.text+0x20): undefined reference tomain' ./Test.o: In function gh::main()': /home/shamma/workspace/Example/Debug/../Test.cpp:16: undefined reference tocvCreateImage' /home/shamma/workspace/Example/Debug/../Test.cpp:21: undefined reference to cvNamedWindow' /home/shamma/workspace/Example/Debug/../Test.cpp:22: undefined reference tocvShowImage' /home/shamma/workspace/Example/Debug/../Test.cpp:23: undefined reference to cvWaitKey' /home/shamma/workspace/Example/Debug/../Test.cpp:24: undefined reference tocvDestroyWindow' /home/shamma/workspace/Example/Debug/../Test.cpp:25: undefined reference to `cvReleaseImage' collect2: ld returned 1 exit status make: * [Example] Error 1enter code here

any idea what might be the cause of the problem, I have tried lots of things without use

thanks in advance

2
As far as I know the problem might be in your code. Do you have a main() function in Test.cpp ? You must.karlphillip

2 Answers

1
votes

It seems you have not properly configured OpenCV libraries. I recommend you to follow the OpenCV tutorial to start using it with Eclipse.

0
votes

In eclipse go to project->properties->settings and under GCC C++ linker-> libraries and assuming you're just testing, add "opencv_core" and "opencv_highgui" there are many more and for each library you need to manually include them so that eclipse can tell the compiler to link these libraries when you run your program.

Also as a note generally "cvE______" is opencv for C where as for C++ it would be cv::E____ , its really confusing that sometime you can get away with both, but not always, so stick the the function in the namespace without cv prefixes.