Valgrind:无法加载可执行程序的共享库
Valgrind: shared libraries for the executable program could not be loaded
我的程序中有一些奇怪的内存相关错误。
它使用 intel mkl,因此依赖于一些特定于 mkl 的共享库。
当我 运行 我的程序时,它在完成大部分工作后出现段错误。段错误发生在对非空文件指针的函数调用 fclose() 中。
当我 运行 我的程序通过 gdb 时,堆栈跟踪不是很有用。
因此我想 运行 valgrind 来查找我的代码中可能存在的错误。
但是,我不能 运行 来自 valgrind 的可执行文件。它打印以下错误消息。
==52778== Memcheck, a memory error detector
==52778== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==52778== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==52778== Command: ./main.exe
==52778==
./main.exe: error while loading shared libraries: libmkl_intel_lp64.so: cannot open shared object file: No such file or directory
共享库 libmkl_intel_lp64.so 存在于同一目录中(以及我的可执行文件所依赖的所有其他共享库)。
如何解决这个问题,以便我可以 valgrind 我的代码?
谢谢。
编辑:我还将环境变量 LD_LIBRARY_PATH 设置(并检查)到当前目录,但没有帮助。
编辑:运行 Linux 64 位,使用英特尔编译器 2017
The shared library libmkl_intel_lp64.so is present in the same
directory (as well as all other shared libraries that my executable
depends upon).
How do I resolve this problem, so that I can valgrind my code?
valgrind
为各种功能提供了很多它自己的环境和包装器来完成它的工作。由于您已设置 LD_LIBRARY_PATH
并且在查找您的库时仍然遇到问题,因此您的另一个选择是使用包含该库的链接器选项 -rpath=/path/to/dir
在可执行文件本身中提供库搜索路径。添加到编译字符串将是:
-Wl,-rpath=/path/to/dir /* that has libmkl_intel_lp64.so in it */
那么查找库不依赖于外部环境,也不希望valgind
将其库搜索扩展到当前工作目录。
(很高兴它起作用了)
我的程序中有一些奇怪的内存相关错误。
它使用 intel mkl,因此依赖于一些特定于 mkl 的共享库。
当我 运行 我的程序时,它在完成大部分工作后出现段错误。段错误发生在对非空文件指针的函数调用 fclose() 中。
当我 运行 我的程序通过 gdb 时,堆栈跟踪不是很有用。
因此我想 运行 valgrind 来查找我的代码中可能存在的错误。
但是,我不能 运行 来自 valgrind 的可执行文件。它打印以下错误消息。
==52778== Memcheck, a memory error detector
==52778== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==52778== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==52778== Command: ./main.exe
==52778==
./main.exe: error while loading shared libraries: libmkl_intel_lp64.so: cannot open shared object file: No such file or directory
共享库 libmkl_intel_lp64.so 存在于同一目录中(以及我的可执行文件所依赖的所有其他共享库)。
如何解决这个问题,以便我可以 valgrind 我的代码?
谢谢。
编辑:我还将环境变量 LD_LIBRARY_PATH 设置(并检查)到当前目录,但没有帮助。
编辑:运行 Linux 64 位,使用英特尔编译器 2017
The shared library libmkl_intel_lp64.so is present in the same directory (as well as all other shared libraries that my executable depends upon).
How do I resolve this problem, so that I can valgrind my code?
valgrind
为各种功能提供了很多它自己的环境和包装器来完成它的工作。由于您已设置 LD_LIBRARY_PATH
并且在查找您的库时仍然遇到问题,因此您的另一个选择是使用包含该库的链接器选项 -rpath=/path/to/dir
在可执行文件本身中提供库搜索路径。添加到编译字符串将是:
-Wl,-rpath=/path/to/dir /* that has libmkl_intel_lp64.so in it */
那么查找库不依赖于外部环境,也不希望valgind
将其库搜索扩展到当前工作目录。
(很高兴它起作用了)