Ask Your Question
1

Compiling errors in header files

asked 2013-07-24 15:59:35 -0600

DrDonut gravatar image

updated 2013-07-26 04:00:59 -0600

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 forvoid 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!

edit retag flag offensive close merge delete

Comments

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 :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-24 17:01:59 -0600 )edit
2

Also if you link core, imgproc and highgui, add these extra includes:

 #include "opencv2/core/core.hpp"
 #include "opencv2/imgproc/imgproc.hpp"

And be sure that you didn't forget to set your windows path variable!

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-24 17:04:38 -0600 )edit
2

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!

DrDonut gravatar imageDrDonut ( 2013-07-25 06:56:26 -0600 )edit

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.

Sushilkumar gravatar imageSushilkumar ( 2013-10-27 02:48:13 -0600 )edit

Please open your own topic, specifying your code, errors, system configuration, ...

StevenPuttemans gravatar imageStevenPuttemans ( 2013-10-28 08:10:01 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-07-26 04:00:21 -0600

- please accept so that this topic shows solved -

Also if you link core, imgproc and highgui, add these extra includes:

 #include "opencv2/core/core.hpp"
 #include "opencv2/imgproc/imgproc.hpp"

And be sure that you didn't forget to set your windows path variable!

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-07-24 15:59:35 -0600

Seen: 4,162 times

Last updated: Jul 26 '13