title: Visual C++ with included OpenCV 2.4.9 compile error
body: <p>I am trying to write a code to display a video from camera on a windows form in Visual Studio 2010 environment. Here below is my code:</p>
  
  <pre><code>#pragma once
  
  #include &lt;opencv\cv.h&gt;
  
  #include &lt;opencv\highgui.h&gt;
  
  extern CvCapture* cam;
  extern IplImage* image,*image_copy;
  static CvMemStorage* storage = 0;
  static CvHaarClassifierCascade* cascade = 0;
  extern const char* cascade_name;
  
  private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
  
  
           cam=cvCaptureFromCAM(-1);
           image=cvQueryFrame(cam);
           if ((videoBox-&gt;Image==nullptr))
           {
               Bitmap^img1=gcnew Bitmap(videoBox-&gt;Width,videoBox-&gt;Height);
               videoBox-&gt;Image=img1;
           }
           cascade=(CvHaarClassifierCascade*)cvLoad(cascade_name,0,0,0);
           storage=cvCreateMemStorage(0);
           if(cam)
           {
               {
                   if(!image_copy)
                       image_copy=cvCreateImage(cvSize(image-&gt;width,image-&gt;height),IPL_DEPTH_8U,image-&gt;nChannels);
                   if(image-&gt;origin==IPL_ORIGIN_TL)
                       cvCopy(image,image_copy,0);
                   else cvFlip(image,image_copy,0);
                   //khai bao mang mau
                       static CvScalar colors[] = 
                       {
                           {{0,0,255}},//red
                           {{0,128,255}},//orange
                           {{0,255,255}},//cyan
                           {{0,255,0}},//green
                           {{255,128,0}},//blue
                           {{255,255,0}},//yellow
                           {{255,0,0}},//blue+
                           {{255,0,255}}//pink
                       };
  
                       double scale = 1.3;
                       IplImage* gray = cvCreateImage( cvSize(image_copy-&gt;width,image_copy-&gt;height), 8, 1 );
                       IplImage* small_img = cvCreateImage( cvSize( cvRound (image_copy-&gt;width/scale),cvRound (image_copy-&gt;height/scale)),8,1);
                       //int i;
                       cvCvtColor( image_copy, gray, CV_BGR2GRAY );
                       cvResize( gray, small_img, CV_INTER_LINEAR );
                       cvEqualizeHist( small_img, small_img );
                       cvClearMemStorage( storage );
  
                   Graphics^ g = Graphics::FromImage(videoBox-&gt;Image);
  
                   Bitmap^ anh2 = gcnew Bitmap(image_copy-&gt;width,image_copy-&gt;height,image_copy-&gt;widthStep,System::Drawing::Imaging::PixelFormat::Format24bppRgb, IntPtr(image_copy-&gt;imageData));
  
                   g-&gt;DrawImage(anh2, (videoBox-&gt;Width-image_copy-&gt;width)/2, (videoBox-&gt;Height-image_copy-&gt;height)/2);
                   videoBox-&gt;Refresh();
                   delete(g);
               }
           }
       }
  </code></pre>
  
  <p>};
  }</p>
  
  <p>At first, .NET Framework 4.5.1 was installed on my computer. But when I compiled the code, I received this error:</p>
  
  <p>"LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt"</p>
  
  <p>I looked for solution and found that Visual Studio 2010 just works with .NET Framework 4. I uninstalled version 4.5.1 and installed version 4. But after that, I received this error:</p>
  
  <pre><code>1&gt;Manual_Mode.obj : error LNK2020: unresolved token (0A0007F1) "extern "C" void __cdecl cvClearMemStorage(struct CvMemStorage *)" (?cvClearMemStorage@@$$J0YAXPAUCvMemStorage@@@Z)
  1&gt;Control_Interface.obj : error LNK2028: unresolved token (0A0007FF) "extern "C" void __cdecl cvClearMemStorage(struct CvMemStorage *)" (?cvClearMemStorage@@$$J0YAXPAUCvMemStorage@@@Z) referenced in function "private: void __clrcall Control_Interface::Manual_Mode::timer1_Tick(class System::Object ^,class System::EventArgs ^)" (?timer1_Tick@Manual_Mode@Control_Interface@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
  1&gt;Control_Interface.obj : error LNK2019: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd@cv@@$$FYAHPAHH@Z) referenced in function "public: void __thiscall cv::SparseMat::addref(void)" (?addref@SparseMat@cv@@$$FQAEXXZ)
  1&gt;Manual_Mode.obj : error LNK2001: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd@cv@@$$FYAHPAHH@Z)
  1&gt;C:\Users\admin\Desktop\Control_Interface\Debug\Control_Interface.exe : fatal error LNK1120: 51 unresolved externals
  </code></pre>
  
  <p>Can you please tell me how to deal with this?</p>