系統是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)
請問如何解決?
过去多啦不再A梦2017-05-16 13:30:15
後來發現之前用Anaconda裝過舊版的MinGW,為了編譯一些Python套件。
先把環境變數刪除,然後conda uninstll mingw
,重新啟動後重裝MinGW,再設定環境變數。現在可以用了。