Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6403 Discussions

Linking OpenVINO DLLs to a program compiled with MinGW

catriona
Beginner
1,654 Views

Hello,

is it possible to link InferenceEngine DLLs (compiled with MSVC) to a program compiled for Windows with MinGW?

I have a CMake-based software project that I would like to compile for Linux (GCC) and Windows (MinGW). I use find_package() with manually set ${InferenceEngine_DIR}, ${ngraph_DIR} and ${TBB_DIR} variables to locate the shared libraries. Building for Linux works correctly, however, when I build for Windows with MinGW compiler, InferenceEngine libraries are not found, specifically, the following commands in InferenceEngineConfig.cmake file from the OpenVINO distribution fail to find any libraries:

find_library(IE_RELEASE_LIBRARY inference_engine "${IE_LIB_REL_DIR}" NO_DEFAULT_PATH)
find_library(IE_LEGACY_RELEASE_LIBRARY inference_engine_legacy "${IE_LIB_REL_DIR}" NO_DEFAULT_PATH)
find_library(IE_C_API_RELEASE_LIBRARY inference_engine_c_api "${IE_LIB_REL_DIR}" NO_DEFAULT_PATH)

I checked the paths and they are correct: ${IE_LIB_REL_DIR} folder contains inference_engine.dll and other InferenceEngine DLL files. CMake is also aware that it is compiling for Windows ("if (WIN32)" is true).

At this point, I am not sure if it is generally not possible to link to InferenceEngine DLLs when compiling with MinGW or if my CMake script is missing something.

Additional information

Development environment: Ubuntu 18.04, OpenVINO 2021.1.110, CMake 3.16.

My MinGW Windows toolchain contains the following:

SET(CMAKE_SYSTEM_NAME Windows)
SET(CROSS_COMPILE_TOOLCHAIN_PREFIX "x86_64-w64-mingw32")
SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

get_filename_component(openvino_DIR "${PROJECT_SOURCE_DIR}/3rdparty/openvino_2021.1.110" ABSOLUTE CACHE)
set(InferenceEngine_DIR ${openvino_DIR}/deployment_tools/inference_engine/share)
set(ngraph_DIR ${openvino_DIR}/deployment_tools/ngraph/cmake)
set(TBB_DIR ${openvino_DIR}/deployment_tools/inference_engine/external/tbb/cmake)
set(OpenCV_DIR ${openvino_DIR}/opencv/cmake)

 

0 Kudos
5 Replies
catriona
Beginner
1,629 Views

Update:

I have since discovered that the issue was caused by CMake that, in newer versions, no longer searches for DLL files unless it is explicitly requested. The following addition to my CMake file fixed it:

set(CMAKE_FIND_LIBRARY_SUFFIXES .dll ${CMAKE_FIND_LIBRARY_SUFFIXES})

 

Additional information for all who wish to use OpenVINO DLLs with MinGW:

TBB libraries cannot be linked by using TBBConfig.cmake / find_package() (TBBConfig.cmake is only compatible with MSVC). A workaround is to either write ones own Cmake file or link TBB and all its dependencies manually.

 

Unfortunately, I cannot test whether the final program also executes correctly, since I have other, unrelated runtime issues. Nevertheless, the original issue is now resolved.

0 Kudos
dnl_anoj
Beginner
1,531 Views

Hi I have the same issue you had and I would like to know if you managed to use OpenVINOs DLLS with MingW! 
I managed to build TBB with MingW using this repository: https://github.com/wjakob/tbb which is a fork of the TBB github with a CMAKE system but I am stuck building OpenVINO.

Could you tell me if you succeded and how? 

Thank you!

0 Kudos
catriona
Beginner
1,514 Views

Hello,

as I mentioned in the update to my original post, my issue was with CMake not searching for DLL files when linking (it searches for static libraries by default). I have posted the solution that worked for me in the update to the original post as well.

As for TBB, I figured out that I don't have to link to it in my own software at all. OpenVINO links to TBB already, so TBB DLLs should simply be located somewhere where OpenVINO can find them at runtime (in my case, they are in the same folder).

0 Kudos
IntelSupport
Moderator
1,619 Views

Hi catriona,

 

Thank you for sharing this information. We highly value your cooperation.

 

Regards,

Adli

 

0 Kudos
IntelSupport
Moderator
1,591 Views

Hi Catriona,


Thank you for your question. If you need any additional information from Intel, please submit a new question as this thread is no longer being monitored.


Regards,

Adli


0 Kudos
Reply