GDB:wrong library or version mismatch?

实际项目中,常常会遇到程序运行环境与本地环境不一致的情况。一般GBG会报如下错误:
warning: .dynamic section for "/lib64/librt.so.1" is not at the expected address (wrong library or version mismatch?)
。。。。。。
Do you need "set solib-search-path" or "set sysroot"?

上述错误提示意思是库错误或者库的版本不匹配。实际看下库版本

运行环境
lrwxrwxrwx 1 root root 15  8月 14 13:28 /lib64/librt.so.1 -> librt-2.11.3.so
本地环境
lrwxrwxrwx 1 root root 15 Oct 15  2020 /lib64/librt.so.1 -> librt-2.11.1.so

解决方法:

需要搭建与程序运行环境一致的环境(装一个和运行环境操作系统版本一样的系统),保证操作系统及glibc版本一致。

GNU gdb (GDB) 7.8.2
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
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-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gbsg...done.
[New LWP 5128]
[New LWP 5129]
[New LWP 5106]
[New LWP 5103]
[New LWP 5108]
[New LWP 5107]
[New LWP 5116]
[New LWP 5117]
[New LWP 5112]
[New LWP 5121]
[New LWP 5111]
[New LWP 5126]
[New LWP 5120]
[New LWP 5114]
[New LWP 5118]
[New LWP 5113]
[New LWP 5119]
[New LWP 5124]
[New LWP 5125]
[New LWP 5105]
[New LWP 5123]
[New LWP 5109]
[New LWP 5115]
[New LWP 5127]
[New LWP 5110]
[New LWP 5122]
[New LWP 5104]

warning: .dynamic section for "/lib64/librt.so.1" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/lib64/libcrypt.so.1" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/lib64/libpthread.so.0" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/lib64/libdl.so.2" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/lib64/libz.so.1" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/lib64/libm.so.6" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/lib64/ld-linux-x86-64.so.2" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/lib64/libnss_files.so.2" is not at the expected address (wrong library or version mismatch?)

warning: Could not load shared library symbols for /lib64/libgcc_s.so.1.
Do you need "set solib-search-path" or "set sysroot"?

你可能感兴趣的:(代码调试,GDB,代码调试,GDB,linux,C++)