项目场景:Linux(Ubuntu)系统使用cuda-gdb调试
问题描述:cuda-gdb无法启动,出现库文件无法找到的错误,在网上找了很多文章都无法顺利解决该问题。。。
username:~$ cuda-gdb
cuda-gdb: error while loading shared libraries: libncursesw.so.5: cannot open shared object file: No such file or directory
原因分析:在尝试了大量文章介绍的方法无果后,我一度想要放弃。。。直到我尝试了下面这篇文章的第4条方法才终于成功了 error while loading shared libraries: xxx.so.x"错误的原因和解决办法 。看来这个问题主要是由于cuda-gdb程序需要的库文件比系统目前存在的文件版本低。
解决方案:首先要找到所需文件的正确位置,然后建立软链接。我根据这篇文章(解决cannot open shared object file: No such file or directory)介绍的ldd命令,先查看cuda-gdb的库依赖关系,如下:
username:/usr/local/cuda-11.0/bin$ ldd cuda-gdb
linux-vdso.so.1 (0x00007fffa59f6000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fe666a43000)
libncursesw.so.5 => not found
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe666a3d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe6668ee000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe6668cb000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe6666d9000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe666a89000)
发现除了libncursesw.so.5文件外的其他文件都在/lib/x86_64-linux-gnu/目录下,因此,我在该目录中寻找libncursesw.so.5的类似文件,发现已经有了libncursesw.so.6,因此只需根据文章(error while loading shared libraries: xxx.so.x"错误的原因和解决办法)介绍的建立软链接的方法,就可以解决问题了,具体代码如下:
username:~$ sudo ln -s /lib/x86_64-linux-gnu/libncursesw.so.6 /lib/x86_64-linux-gnu/libncursesw.so.5
之后就可以正常启动cuda-gdb了:
username:~$ cuda-gdb
NVIDIA (R) CUDA Debugger
11.0 release
Portions Copyright (C) 2007-2020 NVIDIA Corporation
GNU gdb (GDB) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(cuda-gdb)