GDB错误不以可执行格式:未识别的文件格式
gdb error not in executable format: File format not recognized
我正在尝试在Ubuntu 16.04上调试一个简单的" Hello World" C 程序,但GDB无法识别可执行文件格式。但是,我能够在命令行上成功运行可执行文件。这是代码
#include <iostream>
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
我使用命令
编译程序文件testproject.cppg++ -g TestProject.cpp -o hello
然后进行调试,我给命令
gdb ./hello
我收到以下错误消息
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 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 "i686-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"...
"/home/<home>/./hello": not in executable format: File format not recognized
ubuntu机器似乎损坏了。因为我能够在另一台Ubuntu 16.04虚拟机上调试同一程序。
几乎确定KS1322的评论是正确的:
- 您已经安装了64位GCC,因此您的
./hello
是64位二进制(使用file ./hello
确认)。 - 您已经安装了32位GDB,因此它不知道如何调试
x86_64
二进制文件。
修复程序很简单:安装64位GDB(能够同时调试32和64位二进制文件),或或以32位模式构建hello
(使用g++ -m32 ...
)。
我在Mac OS上也有相同的问题。GDB中有一个错误:https://sourceware.org/bugzilla/show_bug.cgi?id=23746他们的GIT存储库已经有了修复。不幸的是,Homebrew中的垃圾箱还没有。因此,我不得不git clone git://sourceware.org/git/binutils-gdb.git,对其进行了编译并安装,如readme文件中所述。我确实相信这将在Ubuntu上解决您的问题。
P.S。它在我的机器上工作,但我必须以root的蚀态运行日食:sudo/.../macos/eclipse。否则,我将启动:配置GDB中止配置GDB。因为我不知道如何修复它(
相关文章:
- 如何在openssl-ecc中获取十六进制格式的私钥
- 提升 ASIO 无法识别计时器对象
- 从udp接收帧对于人脸识别来说太慢
- 将"打开的CV图像"中的"颜色"转换为整数格式
- C++ 编译错误:gnu_printf是无法识别的格式函数类型
- 生成库失败:无法识别文件格式;作为链接器脚本处理
- MySQL C++连接器:添加符号时出错:文件格式无法识别
- /usr/bin/ld找不到标头:未识别的文件格式
- TensorFlow图像识别输出格式C
- GDB错误不以可执行格式:未识别的文件格式
- QFile 无法识别 file:/// 网址路径格式
- g++文件格式无法识别;将Object.o视为链接器脚本
- 尝试生成makefile时无法识别文件格式
- eclipse cdt cygwin gdb stackdump不是核心转储文件格式无法识别
- 如何使用opencv计算人脸识别的百分比格式预测置信度
- 将注释识别为配置的一部分的配置文件格式
- 链接c++静态库与android ndk时出错(错误:无法识别文件格式)
- 无法识别文件格式;作为链接器脚本处理
- 在g++中添加-M标志会导致文件格式不可识别错误
- 不是可执行格式:文件格式无法识别 GDB