简体   繁体   中英

a fatal error in compiling a c++ program

I am using eclipse kepler for C++, in compiling a simple hello world program I saw this error.

c:\mingw\include\_mingw.h:73:20: fatal error: w32api.h: No such file or directory

while the whole windows is as bellow.

09:15:59 **** Incremental Build of configuration Debug for project project1 ****
Info: Internal Builder is used for build
g++ "-IC:\\MinGW\\lib\\gcc\\mingw32\\5.3.0\\include\\c++" "-IC:\\MinGW\\lib\\gcc\\mingw32\\5.3.0\\include\\c++\\backward" "-IC:\\MinGW\\lib\\gcc\\mingw32\\5.3.0\\include" "-IC:\\MinGW\\lib\\gcc\\mingw32\\5.3.0\\include-fixed" "-IC:\\MinGW\\lib\\gcc\\mingw32\\5.3.0\\include\\c++\\mingw32" "-IC:\\MinGW\\include" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\project1.o" "..\\src\\project1.cpp" 
In file included from c:\mingw\include\wchar.h:53:0,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:44,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\postypes.h:40,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:40,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
                 from ..\src\project1.cpp:2:
c:\mingw\include\_mingw.h:73:20: fatal error: w32api.h: No such file or directory
compilation terminated.

09:16:01 Build Finished (took 2s.535ms)

what can I do? my code is this

#include <iostream>
using namespace std;
int main()
{
     cout<<"hello world";
}

In my case i've solved like this:

  1. Go to MinGW Installation Manager.
  2. Select "Basic Setup" from installation list and tick the package "mingw32-base-bin".
  3. From the installation tab select "Apply Changes".

the problem is related to the MinGW installer. there is a package that must be installed, but it didn't install it. go to the MinGW installer and add the ming-w32-w32.api and then apply changes from installation menu.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM