Win+MinGW cannot use gdb to debug C++ compiled exe
巴扎黑
巴扎黑 2017-05-16 13:28:15
0
1
850

The system is Windows 10 x64, MinGW has been installed, the version is:
mingw32-gcc 5.3.0-3
mingw32-gcc-g++ 5.3.0-3
mingw32-gdb 7.6.1- 1
Now I try to compile and debug a cpp code test1.cpp:

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

Then compile using g++:

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

Pass, get test1.exe, and then use gdb to debug:

gdb test1.exe
Getting error:
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)

How to solve it?

巴扎黑
巴扎黑

reply all(1)
过去多啦不再A梦

Later I discovered that I had used Anaconda to install an old version of MinGW in order to compile some Python packages.
First delete the environment variables, then conda uninstll mingwrestart and reinstall MinGW, and then set the environment variables. It's ready to use now.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template