From 387214a3c5551cf061bf7a0643361852f58dc82b Mon Sep 17 00:00:00 2001 From: jiakai Date: Mon, 21 Dec 2015 12:04:00 +0800 Subject: [PATCH 1/2] do not open libopencl by dlopen if HAVE_OPENCL is not set --- modules/core/src/ocl.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index eed4ee5d37..40fa91d984 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -685,9 +685,12 @@ typedef struct _cl_buffer_region { #define CL_CALLBACK CV_STDCALL static volatile bool g_haveOpenCL = false; -static const char* oclFuncToCheck = "clEnqueueReadBufferRect"; -#if defined(__APPLE__) +#ifdef HAVE_OPENCL +static const char* oclFuncToCheck = "clEnqueueReadBufferRect"; +#endif + +#if defined(__APPLE__) && defined(HAVE_OPENCL) #include static void* initOpenCLAndLoad(const char* funcname) @@ -716,7 +719,7 @@ static void* initOpenCLAndLoad(const char* funcname) return funcname && handle ? dlsym(handle, funcname) : 0; } -#elif defined WIN32 || defined _WIN32 +#elif (defined WIN32 || defined _WIN32) && defined(HAVE_OPENCL) #ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?) #define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx @@ -751,7 +754,7 @@ static void* initOpenCLAndLoad(const char* funcname) return funcname ? (void*)GetProcAddress(handle, funcname) : 0; } -#elif defined(__linux) +#elif defined(__linux) && defined(HAVE_OPENCL) #include #include From 22599a28122e9e7698f09935d9f7a238f710ca41 Mon Sep 17 00:00:00 2001 From: jiakai Date: Mon, 21 Dec 2015 16:42:38 +0800 Subject: [PATCH 2/2] define g_haveOpenCL only when HAVE_OPENCL is set --- modules/core/src/ocl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 40fa91d984..6780d85e57 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -684,10 +684,10 @@ typedef struct _cl_buffer_region { #define CL_CALLBACK CV_STDCALL -static volatile bool g_haveOpenCL = false; #ifdef HAVE_OPENCL static const char* oclFuncToCheck = "clEnqueueReadBufferRect"; +static volatile bool g_haveOpenCL = false; #endif #if defined(__APPLE__) && defined(HAVE_OPENCL)