Compilation error with tdm-mingw (4.7.1) in case of enabled c++11 (Bugfix #2555)


Added by Daniel Takacs over 12 years ago. Updated about 12 years ago.


Status:Done Start date:2012-11-19
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:core
Target version:2.4.3.2
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:https://github.com/Itseez/opencv/pull/239

Description

If you try to compile something with enabled c++11 support it will fail with a linker error:
undefined reference: __sync_fetch_and_add

The root of the problem is the definition of CV_XADD in Core/operations.hpp:67:

    #if !defined WIN32 && (defined __i486__ || defined __i586__ || \
        defined __i686__ || defined __MMX__ || defined __SSE__  || defined __ppc__)
      #define CV_XADD __sync_fetch_and_add
    #else
      #include <ext/atomicity.h>
      #define CV_XADD __gnu_cxx::__exchange_and_add
    #endif

At the first line it checks whether it's on Windows or not (i.e. MINGW or not), but it checks only WIN32 but not _WIN32.
According to the MSDN the "standard" is _WIN32, and it looks like the WIN32 is not defined in C++0x mode in TDM-MINGW

I think the safe solution would be to change the first line to something like this:

    #if !(defined WIN32 OR defined _WIN32) && (defined __i486__ || defined __i586__ || \


Associated revisions

Revision 64f82190
Added by Daniel Takacs about 12 years ago

Add missing _WIN32 check in core/operations.hpp.

Fix a compilation error with MinGW gcc 4.7 with enabled C++11 support (-std=c++11).
Issue number: #2555

History

Updated by Vadim Pisarevsky over 12 years ago

lowered priority of the bug to more reasonable.

  • Priority changed from Blocker to Normal

Updated by Andrey Kamaev over 12 years ago

  • Target version set to 2.4.4

Updated by Kirill Kornyakov over 12 years ago

Changed the ticket type to Patch, since the solution is proposed. BTW, am I right that the correct line should look like this (replaced OR with ||):

    #if !(defined WIN32 || defined _WIN32) && (defined __i486__ || defined __i586__ || \ 

Daniel, it would be great if you could prepare a pull request at the GitHub. This would radically speedup the fixing process.

  • Tracker changed from Bug to Patch

Updated by Kirill Kornyakov over 12 years ago

  • Tracker changed from Patch to Bugfix

Updated by Daniel Takacs about 12 years ago

Kirill Kornyakov wrote:

Changed the ticket type to Patch, since the solution is proposed. BTW, am I right that the correct line should look like this (replaced OR with ||):

[...]

Daniel, it would be great if you could prepare a pull request at the GitHub. This would radically speedup the fixing process.

Yes, || indeed.
I will try to make a pull request then...

Updated by Daniel Takacs about 12 years ago

Created a pull request with the necessary change.

Updated by Kirill Kornyakov about 12 years ago

  • Pull request set to https://github.com/Itseez/opencv/pull/239

Updated by Daniel Takacs about 12 years ago

Created a new pull request against the 2.4 branch.

Updated by Andrey Kamaev about 12 years ago

Fix is pushed to 2.4 branch.

  • Target version changed from 2.4.4 to 2.4.3.2
  • Status changed from Open to Done

Also available in: Atom PDF