Author Topic: Codeblock+opencv+windows - strange errors  (Read 9197 times)

Berial

  • Guest
Codeblock+opencv+windows - strange errors
« on: March 01, 2010, 02:35:17 pm »
Hi
I have problem with linking opencv and codeblocks on Windows Vista. On linux everytghing works great, however I would also like to have working opencv library on Windows. So I added
Code: [Select]
-lcxcore -lcv -lcvaux -lhighgui -lml -lcvcam
to linker options, furthermore I added
Code: [Select]
C:\OpenCV2.0\src
C:\OpenCV2.0\include\opencv
C:\OpenCV2.0\lib
to search directories. Unfortunatelly I can't compile any program now, even programs without any of opencv functions.
I got error
Code: [Select]
ld.exe||cannot find -lcxcore|
||=== Build finished: 1 errors, 0 warnings ===|
When I add
Code: [Select]
#include <cv.h>
to main.cpp file I got a lot of errors
Code: [Select]
-------------- Build: Debug in opencvwindows ---------------

Compiling: main.cpp
In file included from C:/OpenCV2.0/include/opencv/cxcore.hpp:2243,
                 from C:/OpenCV2.0/include/opencv/cxcore.h:2123,
                 from C:/OpenCV2.0/include/opencv/cv.h:58,
                 from D:\Tomek\Programowanie\Rozpoznawanie obrazˇw\codeblocks\windows\opencvwindows\main.cpp:2:
C:/OpenCV2.0/include/opencv/cxoperations.hpp: In member function `void cv::Ptr<_Tp>::addref()':
C:/OpenCV2.0/include/opencv/cxoperations.hpp:1442: error: there are no arguments to `__exchange_and_add' that depend on a template parameter, so a declaration of `__exchange_and_add' must be available
C:/OpenCV2.0/include/opencv/cxoperations.hpp:1442: error: (if you use `-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
C:/OpenCV2.0/include/opencv/cxoperations.hpp: In member function `void cv::Ptr<_Tp>::release()':
C:/OpenCV2.0/include/opencv/cxoperations.hpp:1446: error: there are no arguments to `__exchange_and_add' that depend on a template parameter, so a declaration of `__exchange_and_add' must be available
C:/OpenCV2.0/include/opencv/cxoperations.hpp: In member function `cv::Ptr<_Tp>& cv::Ptr<_Tp>::operator=(const cv::Ptr<_Tp>&)':
C:/OpenCV2.0/include/opencv/cxoperations.hpp:1473: error: there are no arguments to `__exchange_and_add' that depend on a template parameter, so a declaration of `__exchange_and_add' must be available
In file included from C:/OpenCV2.0/include/opencv/cxcore.hpp:2244,
                 from C:/OpenCV2.0/include/opencv/cxcore.h:2123,
                 from C:/OpenCV2.0/include/opencv/cv.h:58,
                 from D:\Tomek\Programowanie\Rozpoznawanie obrazˇw\codeblocks\windows\opencvwindows\main.cpp:2:
C:/OpenCV2.0/include/opencv/cxmat.hpp: In copy constructor `cv::Mat::Mat(const cv::Mat&)':
C:/OpenCV2.0/include/opencv/cxmat.hpp:102: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:102: warning: unused variable '__exchange_and_add'
C:/OpenCV2.0/include/opencv/cxmat.hpp: In constructor `cv::Mat::Mat(const cv::Mat&, const cv::Range&, const cv::Range&)':
C:/OpenCV2.0/include/opencv/cxmat.hpp:174: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:174: warning: unused variable '__exchange_and_add'
C:/OpenCV2.0/include/opencv/cxmat.hpp: In constructor `cv::Mat::Mat(const cv::Mat&, const cv::Rect&)':
C:/OpenCV2.0/include/opencv/cxmat.hpp:189: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:189: warning: unused variable '__exchange_and_add'
C:/OpenCV2.0/include/opencv/cxmat.hpp: In member function `cv::Mat& cv::Mat::operator=(const cv::Mat&)':
C:/OpenCV2.0/include/opencv/cxmat.hpp:239: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:239: warning: unused variable '__exchange_and_add'
C:/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::Mat::addref()':
C:/OpenCV2.0/include/opencv/cxmat.hpp:342: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:342: warning: unused variable '__exchange_and_add'
C:/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::Mat::release()':
C:/OpenCV2.0/include/opencv/cxmat.hpp:346: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:346: warning: unused variable '__exchange_and_add'
C:/OpenCV2.0/include/opencv/cxmat.hpp: In copy constructor `cv::MatND::MatND(const cv::MatND&)':
C:/OpenCV2.0/include/opencv/cxmat.hpp:3648: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:3648: warning: unused variable '__exchange_and_add'
C:/OpenCV2.0/include/opencv/cxmat.hpp: In member function `cv::MatND& cv::MatND::operator=(const cv::MatND&)':
C:/OpenCV2.0/include/opencv/cxmat.hpp:3677: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:3677: warning: unused variable '__exchange_and_add'
C:/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::MatND::addref()':
C:/OpenCV2.0/include/opencv/cxmat.hpp:3717: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:3717: warning: unused variable '__exchange_and_add'
C:/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::MatND::release()':
C:/OpenCV2.0/include/opencv/cxmat.hpp:3722: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:3722: warning: unused variable '__exchange_and_add'
C:/OpenCV2.0/include/opencv/cxmat.hpp: In member function `cv::SparseMat& cv::SparseMat::operator=(const cv::SparseMat&)':
C:/OpenCV2.0/include/opencv/cxmat.hpp:4081: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:4081: warning: unused variable '__exchange_and_add'
C:/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::SparseMat::addref()':
C:/OpenCV2.0/include/opencv/cxmat.hpp:4112: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:4112: warning: unused variable '__exchange_and_add'
C:/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::SparseMat::release()':
C:/OpenCV2.0/include/opencv/cxmat.hpp:4116: error: `__exchange_and_add' was not declared in this scope
C:/OpenCV2.0/include/opencv/cxmat.hpp:4116: warning: unused variable '__exchange_and_add'
Process terminated with status 1 (0 minutes, 4 seconds)
17 errors, 13 warnings
So could sb tell me what did I do wrong? I didn't have problem with linking this library on linux, however on windows it is terrible experience.
PS
I use codeblocks 8.02 and OpenCV 2.0a

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5237
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Codeblock+opencv+windows - strange errors
« Reply #1 on: March 02, 2010, 06:57:27 am »
If I remember correctly, opencv 2.0 library is build in TDM-GCC 4.xxx. And the compiler bundled with Codeblocks8.02 is using an old GCC.

I suggest you should use a more recent Codeblocks version, such as a  nightly build version.

Also, a more recent GCC compiler, such as TDM GCC.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

DavidM

  • Guest
Re: Codeblock+opencv+windows - strange errors
« Reply #2 on: March 02, 2010, 08:06:03 am »
In  OpenCV2.0\include\opencv\cxoperations.hpp
change line 68 from
Code: [Select]
        #if __GNUC__ >= 4To
Code: [Select]
        #if __GNUC__ >= 4 || __MINGW32__

Offline Vuki

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Codeblock+opencv+windows - strange errors
« Reply #3 on: March 02, 2010, 09:00:07 am »
Code: [Select]
-lcxcore -lcv -lcvaux -lhighgui -lml -lcvcam

Code: [Select]
ld.exe||cannot find -lcxcore|
||=== Build finished: 1 errors, 0 warnings ===|

Check filenames in C:\OpenCV2.0\lib. If you use pre-built version for Windows, there is no libcxcore.a file there, the file is named libcxcore200.dll.a. Therefore, you need to use -lcxcore200.dll instead. The same rule applies to other libraries (-lcv200.dll and so on).

As for compiler errors, I think you use old compiler version (3.x). Updating to gcc 4 should make it work.