mirror of
https://github.com/opencv/opencv.git
synced 2026-09-19 15:23:23 -05:00
Merge pull request #9449 from ribalda:ocv
This commit is contained in:
@@ -134,6 +134,24 @@ static void* WinGetProcAddress(const char* name)
|
|||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static void *GetHandle(const char *file)
|
||||||
|
{
|
||||||
|
void *handle;
|
||||||
|
|
||||||
|
handle = dlopen(file, RTLD_LAZY | RTLD_GLOBAL);
|
||||||
|
if (!handle)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (dlsym(handle, OPENCL_FUNC_TO_CHECK_1_1) == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, ERROR_MSG_INVALID_VERSION);
|
||||||
|
dlclose(handle);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
static void* GetProcAddress(const char* name)
|
static void* GetProcAddress(const char* name)
|
||||||
{
|
{
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
@@ -143,20 +161,18 @@ static void* GetProcAddress(const char* name)
|
|||||||
cv::AutoLock lock(cv::getInitializationMutex());
|
cv::AutoLock lock(cv::getInitializationMutex());
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
{
|
{
|
||||||
const char* path = "libOpenCL.so";
|
|
||||||
const char* envPath = getenv("OPENCV_OPENCL_RUNTIME");
|
const char* envPath = getenv("OPENCV_OPENCL_RUNTIME");
|
||||||
if (envPath)
|
if (envPath)
|
||||||
path = envPath;
|
|
||||||
handle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
|
|
||||||
if (handle == NULL)
|
|
||||||
{
|
{
|
||||||
if (envPath)
|
handle = GetHandle(envPath);
|
||||||
|
if (!handle)
|
||||||
fprintf(stderr, ERROR_MSG_CANT_LOAD);
|
fprintf(stderr, ERROR_MSG_CANT_LOAD);
|
||||||
}
|
}
|
||||||
else if (dlsym(handle, OPENCL_FUNC_TO_CHECK_1_1) == NULL)
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, ERROR_MSG_INVALID_VERSION);
|
handle = GetHandle("libOpenCL.so");
|
||||||
handle = NULL;
|
if (!handle)
|
||||||
|
handle = GetHandle("libOpenCL.so.1");
|
||||||
}
|
}
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user