OpenCV use InitializeCriticalSectionEx in release with all version of windows (Bug #2858)


Added by Jean-François Côté about 4 years ago. Updated almost 2 years ago.


Status:Open Start date:2013-03-04
Priority:Low Due date:
Assignee:Jean-François Côté % Done:

0%

Category:build/install
Target version:Next Hackathon
Affected version:branch 'master' (2.4.9) Operating System:Windows
Difficulty: HW Platform:x86
Pull request:

Description

Hi,

First, please read my post here:
http://answers.opencv.org/question/6151/opencv_createsamplesexe-entry-point-problem-with/

The problem is not only in createSamples.exe. I am using emguCV.NET which is a .NET wrapper of openCV. In my code, I am simply calling cvCreateImage and it crash because imgproc249 (or ANY version) can't found InitializeCriticalSectionEx. On my computer in Windows 7, it's all good but on any computer in Windows XP, it crash (I tried on 3 different windows XP computer)

Things to note:
-Only with the openCV DLL compiled in release mode. If I use the debug version with the "d" at the end, the bug doesn't happend.
-Only in Windows XP or previous. The function InitializeCriticalSectionEx is only available in Vista and above.
-The problem can be easily viewed if you drag imgproc2xx.dll to "Dependency Walker" or any DLL dependancy program (See screenshot in the link above). You must do the viewing on a windows XP system.
-I tried compiling in Windows XP itself but the problem is still there.
-Only happend when the WITH_TBB is checked in the makefile. I am able to use the DLL when I re-compiled them without the TBB options. But since we need to have TBB activated in our project, it's kind of blocking.

I tried to look at the openCV code but I can't find anything. I guess InitializeCriticalSectionEx is not called directly in the code...

Thanks


History

Updated by Andrey Kamaev about 4 years ago

Which release of TBB are you using?

Updated by Jean-François Côté about 4 years ago

I use version 4.1.2012.1003

Updated by Andrey Kamaev about 4 years ago

Please try to downgrade to TBB 4.0. If I remember correctly the TBB 4.1 had increased minimal system requirement. Probably that is your problem.

Updated by Andrey Pavlenko about 4 years ago

  • Assignee changed from Andrey Kamaev to Jean-François Côté

Updated by Jean-François Côté about 4 years ago

Yes that was the problem. I think there should have a documentation somewhere in the wiki about this issue.

Updated by Vadim Pisarevsky about 4 years ago

since there is workaround and the problem is not in OpenCV itself, I lower the priority

  • Target version set to Next Hackathon
  • Priority changed from Blocker to Low

Updated by Pierre Chatelier about 4 years ago

In the TBB "Release_Notes.txt", we can read

If an application is built for Microsoft* Windows* XP Professional or similar the _WIN32_WINNT macro must be set
manually to 0x0501 in order to limit the usage of modern API that is available on newer operating systems.

So, adding _WIN32_WINNT=0x0501 as preprocessing directive in the different opencv module projects will fix the problem.

I think it could be an new option of the CMakeFile to build OpenCV

Updated by Olivier Brousse almost 4 years ago

Pierre Chatelier wrote:

In the TBB "Release_Notes.txt", we can read

If an application is built for Microsoft* Windows* XP Professional or similar the _WIN32_WINNT macro must be set
manually to 0x0501 in order to limit the usage of modern API that is available on newer operating systems.

So, adding _WIN32_WINNT=0x0501 as preprocessing directive in the different opencv module projects will fix the problem.

I think it could be an new option of the CMakeFile to build OpenCV

Hello all,

The solution proposed by Pierre is working as a charm. I tested it on XP 32 bit with a software of mine that was not working before I applied Pierre's solution.

To apply it, I just added /D_WIN32_WINNT=0x0501 to CMAKE_CXX_FLAGS and to CMAKE_C_FLAGS definitions in the windows GUI of cmake on the git freshly pulled version. Then building the whole OpenCV solution with visual studio 2010 (and windows SDK 7.1) on window 8 went alright. I then tested the library on win XP SP3 (32bits) and I did not get the "InitializeCriticalSectionEx not found" issue anymore.

Many thanks to Pierre and if some one is able to propose this "patch" on the git repo it would be great (I don't really know how I can do this by myself and i feel ashamed for that).

Olivier.

Updated by Nikita Manovich almost 4 years ago

Olivier,

Thank you for your update. Could you please help us and prepare a pull request? If you have time please read http://www.code.opencv.org/projects/opencv/wiki/How_to_contribute tutorial and submit a fix for the problem. We hope to see you as a contributor. We need your help.

  • HW Platform set to x86
  • Operating System set to Windows
  • Affected version changed from 2.4.3 to branch 'master' (2.4.9)

Updated by Pierre Chatelier almost 4 years ago

Just be careful to make it an optional CMake build option. People building OpenCV for Windows Vista+ certainly prefer to unleash the "modern API" and don't want to see a performance hit because of the legacy support of Windows XP.

Updated by Maksim Shabunin almost 2 years ago

Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4522

Also available in: Atom PDF