0

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

DJames
  • 571
  • 3
  • 17
  • As far as I recall `/MD` is for multi-threaded dynamically linked and you want static linking, which is `/MT`. I don't guarantee that's all you'll need to do though. – Qubit Apr 25 '22 at 10:20
  • if an executable file has a dependency on a library, then the library must be logically _visible_ to the .exe. Your installer must either place the .dll in one of the locations that is searched, or edit the system path variable to include that location. It is just a matter of visibility. – ryyker Apr 25 '22 at 12:53

2 Answers2

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.

Brecht Sanders
  • 6,215
  • 1
  • 16
  • 40
1

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://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order

TonyM
  • 366
  • 1
  • 4