如何制作使用OpenMP并使用Intel c Compiler Portable编译的二进制文件?
通常,我会使用Intel oneapi命令提示符编译代码(全部在单个文件main.c中),这样
icl.exe main.c -o binary_name
我就可以在常规命令提示符中运行biary_name.exe,而不会出现问题。但是,当我最近利用OpenMP多线程并这样的编译时。
icl.exe main.c -o binary_name /Qopenmp /MD /link libiomp5md.lib
我最终希望将此简单的代码移动(例如,使用相同的操作系统)。是否可以通过命令提示符或批处理文件进行某些过程,以包装和链接动态库? Windows上似乎不支持OpenMP的静态链接
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:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
制作静态链接的版本,或与EXE文件一起分发依赖项DLL文件。
您可以使用依赖关系walker 检查EXE的依赖项。
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.
正如您正确说明Windows上不支持OpenMP的静态链接。根据您的用例,您有几个选择。最简单的测试最简单的方法是将动态链接库与可执行文件一起运送,然后将其放在目标系统中的同一目录中。使用DLL构建了许多系统后,通常这是大多数开发人员在生产环境中确保其代码能力的方法。
如果您想在目标系统上做一些更复杂的事情,则可以将动态链接库放在共享位置,并从Microsoft构建站点中遵循搜索订单建议:
https://learn.microsoft.com/en-en-us/windows/windows/windows/windows/win32/win32/dlls/dynamic -link-library-search-order
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