'How can I make a binary that uses openmp and compiled with intel's C compiler portable?

Normally I compile code (all in a single file main.c) with the intel oneapi command prompt like so

icl.exe main.c -o binary_name

I can then run binary_name.exe without issue from a regular command prompt. However, when I recently exploited openmp multithreading and compiled like so.

icl.exe main.c -o binary_name /Qopenmp /MD /link libiomp5md.lib

Then, when I try to run it through an ordinary command prompt, I get this message: openmp5 error

I'd ultimately like to move this simple code around (say, to another computer with the same OS). Is there some procedure through a command prompt or batch file for packaging and linking a dynamic library? It is also looking like statically linking for openmp is not supported on windows



Solution 1:[1]

Either make a statically linked version, or distribute the dependency DLL file(s) along with the EXE file.

You can check the dependencies of your EXE with Dependency Walker.

Solution 2:[2]

As you correctly statedk statically linking for OpenMP is not supported on Windows. Depending on your use case you have a couple of options. The simplest one for simple testing is to just ship the Dynamic-Link Library with you executable and place it in the same directory in the target system. Having built a lot of systems using DLLs, this is typically what most developers do to ensure capability with their code in a production environment even.

If you are looking to do something more complex on the target system you can place the Dynamic-Link library in a shared location and follow the search order suggestions from the Microsoft Build site:

https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brecht Sanders
Solution 2 TonyM-Intel