Win+MinGW不能用gdb调试C++编译的exe
巴扎黑
巴扎黑 2017-05-16 13:28:15
0
1
851

系统是Windows10 x64,已经安装好MinGW,版本是:
mingw32-gcc 5.3.0-3
mingw32-gcc-g++ 5.3.0-3
mingw32-gdb 7.6.1-1
现在我尝试编译并调试一个cpp代码test1.cpp:

#include <iostream>
using namespace std;
int main()
{
    int a;
    cout<<"HelloWorld!"<<endl;
    cin>>a;
}

然后使用g++编译:

g++ -g test1.cpp -o test1.exe

通过,得到test1.exe,然后使用gdb调试:

gdb test1.exe
得到错误:
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 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 "mingw32".
For bug reporting instructions, please see:
http://www.gnu.org/software/g......
"D:CppProjects/test1.exe": not in executable format: File format not recognized
(gdb)

请问如何解决?

巴扎黑
巴扎黑

全部回复(1)
过去多啦不再A梦

后来发现之前用Anaconda装过旧版的MinGW,为了编译一些Python包。
先把环境变量删除,然后conda uninstll mingw,重启后重装MinGW,然后再设置环境变量。现在可以用了。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板