From 5383a625a787307013e14ac9452a3b95bc116725 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 25 Aug 2016 16:21:52 +0300 Subject: [PATCH] fix Win build, change default WINNT macro to WinXP Returning to Win2k value is possible via this CMake option: cmake -DOPENCV_EXTRA_FLAGS="/D_WIN32_WINNT=0x0500" ... --- modules/core/src/parallel.cpp | 2 +- modules/highgui/src/precomp.hpp | 8 -------- modules/imgcodecs/src/precomp.hpp | 8 -------- modules/videoio/src/cap_ffmpeg.cpp | 16 ++++++---------- modules/videoio/src/precomp.hpp | 2 +- 5 files changed, 8 insertions(+), 28 deletions(-) diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index d4968652a3..e4ee8f50ab 100644 --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -521,7 +521,7 @@ int cv::getNumberOfCPUs(void) { #if defined WIN32 || defined _WIN32 SYSTEM_INFO sysinfo; -#if defined(_M_ARM) || defined(_M_X64) || defined(WINRT) +#if (defined(_M_ARM) || defined(_M_X64) || defined(WINRT)) && _WIN32_WINNT >= 0x501 GetNativeSystemInfo( &sysinfo ); #else GetSystemInfo( &sysinfo ); diff --git a/modules/highgui/src/precomp.hpp b/modules/highgui/src/precomp.hpp index 796af39768..31969403b1 100644 --- a/modules/highgui/src/precomp.hpp +++ b/modules/highgui/src/precomp.hpp @@ -61,14 +61,6 @@ #include #if defined WIN32 || defined WINCE - #if !defined _WIN32_WINNT - #ifdef HAVE_MSMF - #define _WIN32_WINNT 0x0600 // Windows Vista - #else - #define _WIN32_WINNT 0x0500 // Windows 2000 - #endif - #endif - #include #undef small #undef min diff --git a/modules/imgcodecs/src/precomp.hpp b/modules/imgcodecs/src/precomp.hpp index 101f01577c..6a16ca865a 100644 --- a/modules/imgcodecs/src/precomp.hpp +++ b/modules/imgcodecs/src/precomp.hpp @@ -59,14 +59,6 @@ #include #if defined WIN32 || defined WINCE - #if !defined _WIN32_WINNT - #ifdef HAVE_MSMF - #define _WIN32_WINNT 0x0600 // Windows Vista - #else - #define _WIN32_WINNT 0x0500 // Windows 2000 - #endif - #endif - #include #undef small #undef min diff --git a/modules/videoio/src/cap_ffmpeg.cpp b/modules/videoio/src/cap_ffmpeg.cpp index 772996e505..26e2ead0cd 100644 --- a/modules/videoio/src/cap_ffmpeg.cpp +++ b/modules/videoio/src/cap_ffmpeg.cpp @@ -65,9 +65,11 @@ static cv::Mutex _icvInitFFMPEG_mutex; static const HMODULE cv_GetCurrentModule() { HMODULE h = 0; +#if _WIN32_WINNT >= 0x0501 ::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, reinterpret_cast(cv_GetCurrentModule), &h); +#endif return h; } #endif @@ -98,22 +100,16 @@ private: icvInitFFMPEG() { #if defined WIN32 || defined _WIN32 - # ifdef WINRT - const wchar_t* module_name = L"opencv_ffmpeg" + const wchar_t* module_name_ = L"opencv_ffmpeg" CVAUX_STRW(CV_MAJOR_VERSION) CVAUX_STRW(CV_MINOR_VERSION) CVAUX_STRW(CV_SUBMINOR_VERSION) #if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__) L"_64" #endif L".dll"; - - icvFFOpenCV = LoadPackagedLibrary( module_name, 0 ); + # ifdef WINRT + icvFFOpenCV = LoadPackagedLibrary( module_name_, 0 ); # else - const std::wstring module_name = L"opencv_ffmpeg" - CVAUX_STRW(CV_MAJOR_VERSION) CVAUX_STRW(CV_MINOR_VERSION) CVAUX_STRW(CV_SUBMINOR_VERSION) - #if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__) - L"_64" - #endif - L".dll"; + const std::wstring module_name(module_name_); const wchar_t* ffmpeg_env_path = _wgetenv(L"OPENCV_FFMPEG_DLL_DIR"); std::wstring module_path = diff --git a/modules/videoio/src/precomp.hpp b/modules/videoio/src/precomp.hpp index 45ce1a1f60..517dc9186b 100644 --- a/modules/videoio/src/precomp.hpp +++ b/modules/videoio/src/precomp.hpp @@ -66,7 +66,7 @@ #ifdef HAVE_MSMF #define _WIN32_WINNT 0x0600 // Windows Vista #else - #define _WIN32_WINNT 0x0500 // Windows 2000 + #define _WIN32_WINNT 0x0501 // Windows XP #endif #endif