Compiling errors in header files
Hi all,
So I decided to try and fiddle around with openCV for a bit, but I cannot seem to get my setup working.
First I did the setup as described in the tutorials, then I tried to compile this very simple demo project:
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
Mat im = imread(argc == 2 ? argv[1] : "lena.jpg", 1);
if (im.empty())
{
cout << "Cannot open image!" << endl;
return -1;
}
imshow("image", im);
waitKey(0);
return 0;
}
Somehow, when I hit compile, it gives me the following errors:
17:45:49 * Incremental Build of configuration Debug for project opencvtest *
Info: Internal Builder is used for build
g++ "-IC:\opencv\build\include" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\opencvtest.o" "..\src\opencvtest.cpp"
In file included from C:/opencv/build/include/opencv2/core/core.hpp:4824,
from C:/opencv/build/include/opencv2/highgui/highgui.hpp:46,
from ..\src\opencvtest.cpp:1:
C:/opencv/build/include/opencv2/core/operations.hpp: In static member function static cv::Ptr<_Tp2> cv::Algorithm::create(const std::string&)':
C:/opencv/build/include/opencv2/core/operations.hpp:3918: error: expected primary-expression before '>' token
C:/opencv/build/include/opencv2/core/operations.hpp:3918: error: expected primary-expression before ')' token
C:/opencv/build/include/opencv2/core/operations.hpp: At global scope:
C:/opencv/build/include/opencv2/core/operations.hpp:3970: error: got 2 template parameters for
void cv::AlgorithmInfo::addParam(cv::Algorithm&, const char, cv::Ptr<_Tp2>&, bool, cv::Ptr<_Tp2> (cv::Algorithm::)(), void (cv::Algorithm::)(const cv::Ptr<_Tp2>&), const std::string&)'
C:/opencv/build/include/opencv2/core/operations.hpp:3970: error: but 1 required
C:/opencv/build/include/opencv2/core/operations.hpp:3979: error: redefinition of void cv::AlgorithmInfo::addParam(cv::Algorithm&, const char*, cv::Ptr<_Tp2>&, bool, cv::Ptr<_Tp2> (cv::Algorithm::*)(), void (cv::Algorithm::*)(const cv::Ptr<_Tp2>&), const std::string&)'
C:/opencv/build/include/opencv2/core/operations.hpp:3970: error:
void cv::AlgorithmInfo::addParam(cv::Algorithm&, const char, cv::Ptr<_Tp2>&, bool, cv::Ptr<_Tp2> (cv::Algorithm::)(), void (cv::Algorithm::)(const cv::Ptr<_Tp2>&), const std::string&)' previously declared here
17:45:51 Build Finished (took 1s.974ms)
As I cannot imagine that there will actually be errors in the header files, there must be something wrong with my setup. Does anyone know what I did wrong?
The setup:
- Platform windows 7 64 bits
- compiler: mingw
- IDE: Eclipse with CDT
- include path (in project settings) c:\opencv\build\include (I copied the contents from \include\opencv to \include, because otherwise the paths to the files in \include\opencv2 would not be correct).
- library path (in project settings): c:\opencv\build\x64\mingw\lib opencv
- version: 2.4.6
- linked librarys: core, imgproc and highgui
Thank you all in advance!
The tutorials for windows 7 state that the include folder is $OPEN_CV$\include. However this is wrong if your OPEN_CV parameter is set as 'C:\opencv\build\x64\vc10'. The correct include path in that case is $OPEN_CV$....\include. It is actually 2 parents folders up :)
Also if you link core, imgproc and highgui, add these extra includes:
And be sure that you didn't forget to set your windows path variable!
Hi, Thank you so much for your answers! Including core and imgproc did the trick! Now I'm still stuck with some other problems, but if needed, I will make a separate question for those.
Thanks you and happy coding!
Hello steven, I am getting same error. I tried out your trick but still I am getting same error. Please help me! Looking forward to your reply.
Please open your own topic, specifying your code, errors, system configuration, ...