加载共享库libmkl_core.so时,如何更改路径以修复错误"./main:错误"? [英] How to change path to fix error "./main: error while loading shared library libmkl_core.so?

查看:211
本文介绍了加载共享库libmkl_core.so时,如何更改路径以修复错误"./main:错误"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了英特尔mkl库.内容的路径为/home/user/intel/......我必须使用提及该文件的make文件来运行C ++代码.

I have installed intel mkl library. contents have path /home/user/intel/..... . I have to run a C++ code using make file on which it is mentioned.

CC = /home/user/intel/bin/icpc -g
INCLUDE = -I/home/user/intel/mkl/include 
LIB = -L/home/user/intel/mkl/lib/intel64 -lmkl_core -lmkl_intel_lp64 -lmkl_intel_thread -liomp5 -lpthread -std=c++11

我已成功安装parallel_studio_xe_2019_update5_cluster_edition.但是仍然在加载共享库时收到错误消息./main:error.我该如何解决此错误.我需要做些什么改变?

I have successfully installed parallel_studio_xe_2019_update5_cluster_edition . but still I'm getting an error message that ./main :error while loading shared libraries. How can I fix this error. What changes I need to do?

推荐答案

与共享库的链接实际上是通过两个步骤完成的:构建时(链接器需要在其中查找库);并且在运行时(当动态加载的操作系统需要查找该库时).

Linking with shared libraries is actually done in two steps: When building (where the linker needs to find the library); And when running (when the operating system dynamic loaded needs to find the library).

使用在非标准位置安装的库进行构建时,请使用-L选项告诉链接器在何处查找库.不幸的是,它没有告诉动态加载器库的位置.

When building with libraries installed in non-standard locations, you tell the linker where to find the library using the -L option. Unfortunately it doesn't tell the dynamic loader where the library is located.

要告诉动态加载器动态库的位置,有两种方法,我建议您在构建时添加一个标志,以便链接器将位置嵌入可执行程序文件中,以供动态加载器查看.这是通过选项-Wl,-rpath,/path/to/lib/directory完成的.

To tell the dynamic loader the location of a dynamic library there are a couple of way, the one I recommend is to add a flag when building so the linker will embed the location inside the executable program file for the dynamic loader to see. This is done with the option -Wl,-rpath,/path/to/lib/directory.

根据您的情况,您需要在LIB makefile变量中添加选项-Wl,-rpath,/home/user/intel/mkl/lib/intel64.

In your case you need to add the option -Wl,-rpath,/home/user/intel/mkl/lib/intel64 to the LIB makefile variable.

为澄清起见,完整行应为

LIB = -L/home/user/intel/mkl/lib/intel64 -Wl,-rpath,/home/user/intel/mkl/lib/intel64 -lmkl_core -lmkl_intel_lp64 -lmkl_intel_thread -liomp5 -lpthread -std=c++11 

也就是说,您都需要两者旧的-L选项(如当前显示的代码中所示) 并添加新选项.

That is, you need both the old -L option (as you current have it in the code you show) and add the new option.

这篇关于加载共享库libmkl_core.so时,如何更改路径以修复错误"./main:错误"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆