Hi all, I am having problem with openCV:
I am using Microsoft Studio 2008
From this lnk: http://sourceforge.net/projects/opencvlibrary/ I downloaded the OpenCV_1.1pre1a.exe for windows and installed it.

I have been searching ways to include the libraries installed but the instructions don't seem to match my VS version?

So after creating a new project I went to the folder where the .cpp and .h files were and started adding the .h files that were installed.
(cv.h ,cxcore.v and so on)

The code was compiling but when I added the highgui.h I got this error:

Error 1 error LNK2019: unresolved external symbol _cvReleaseImage referenced in function _main HelloWorld.obj MyOpenCV
Error 2 error LNK2019: unresolved external symbol _cvWaitKey referenced in function _main HelloWorld.obj MyOpenCV
Error 3 error LNK2019: unresolved external symbol _cvShowImage referenced in function _main HelloWorld.obj MyOpenCV
Error 4 error LNK2019: unresolved external symbol _cvMoveWindow referenced in function _main HelloWorld.obj MyOpenCV
Error 5 error LNK2019: unresolved external symbol _cvNamedWindow referenced in function _main HelloWorld.obj MyOpenCV
Error 6 error LNK2019: unresolved external symbol _cvLoadImage referenced in function _main HelloWorld.obj MyOpenCV
Error 7 fatal error LNK1120: 6 unresolved externals C:\Users\USER\Documents\Visual Studio 2008\Projects\MyOpenCV\Debug\MyOpenCV.exe MyOpenCV

The code was taken from an example on the internet:

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "cv.h"
#include "highgui.h"


int main(int argc, char *argv[])
{
  IplImage* img = 0; 
  int height,width,step,channels;
  uchar *data;
  int i,j,k;

  if(argc<2){
    printf("Usage: main <image-file-name>\n\7");
    exit(0);
  }

  // load an image  
  img=cvLoadImage(argv[1]);
  if(!img){
    printf("Could not load image file: %s\n",argv[1]);
    exit(0);
  }

  // get the image data
  height    = img->height;
  width     = img->width;
  step      = img->widthStep;
  channels  = img->nChannels;
  data      = (uchar *)img->imageData;
  printf("Processing a %dx%d image with %d channels\n",height,width,channels); 

  // create a window
  cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); 
  cvMoveWindow("mainWin", 100, 100);

  // invert the image
  for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++)
    data[i*step+j*channels+k]=255-data[i*step+j*channels+k];

  // show the image
  cvShowImage("mainWin", img );

  // wait for a key
  cvWaitKey(0);

  // release the image
  cvReleaseImage(&img );
  return 0;
}

All I want, is to get the OpenCV to work so I can finally start doing my project.
Any help will be appreciated.
By the way, I was trying to get this thing to work all day yesterday but with no success.

Recommended Answers

All 4 Replies

Did you try:

#include <cv.h>
#include <highgui.h>

?

And oh, by the way, have you already read this?

I did tried both and found relevant sites like the one provided. The problem was that I didn't know how to add the openCV library to my projects. The VS version I was using didn't have the options described at the link. I tried to download the latest VS Express edition but it was not installing.

Luckily I tried it at my work's laptop which didn't have an VS versions installed and it worked.

I will try to uninstall the VS I have installed in my old laptop and try again with the new Express edition.

I did tried both and found relevant sites like the one provided. The problem was that I didn't know how to add the openCV library to my projects. The VS version I was using didn't have the options described at the link.

For Visual Studio 2008: http://opencv.willowgarage.com/wiki/VC2008Express :)

i just started with OPenCV library and tried to start with the same program shown below, and it gives me the same erros, although i added all libraries and header files for opencv library. in directories tab for my project, as i am using visual studio 6.0

Hi all, I am having problem with openCV:
I am using Microsoft Studio 2008
From this lnk: http://sourceforge.net/projects/opencvlibrary/ I downloaded the OpenCV_1.1pre1a.exe for windows and installed it.

I have been searching ways to include the libraries installed but the instructions don't seem to match my VS version?

So after creating a new project I went to the folder where the .cpp and .h files were and started adding the .h files that were installed.
(cv.h ,cxcore.v and so on)

The code was compiling but when I added the highgui.h I got this error:

The code was taken from an example on the internet:

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "cv.h"
#include "highgui.h"


int main(int argc, char *argv[])
{
  IplImage* img = 0; 
  int height,width,step,channels;
  uchar *data;
  int i,j,k;

  if(argc<2){
    printf("Usage: main <image-file-name>\n\7");
    exit(0);
  }

  // load an image  
  img=cvLoadImage(argv[1]);
  if(!img){
    printf("Could not load image file: %s\n",argv[1]);
    exit(0);
  }

  // get the image data
  height    = img->height;
  width     = img->width;
  step      = img->widthStep;
  channels  = img->nChannels;
  data      = (uchar *)img->imageData;
  printf("Processing a %dx%d image with %d channels\n",height,width,channels); 

  // create a window
  cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); 
  cvMoveWindow("mainWin", 100, 100);

  // invert the image
  for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++)
    data[i*step+j*channels+k]=255-data[i*step+j*channels+k];

  // show the image
  cvShowImage("mainWin", img );

  // wait for a key
  cvWaitKey(0);

  // release the image
  cvReleaseImage(&img );
  return 0;
}

All I want, is to get the OpenCV to work so I can finally start doing my project.
Any help will be appreciated.
By the way, I was trying to get this thing to work all day yesterday but with no success.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.