compiling simple hellow world with mingw g++

无人久伴 提交于 2020-03-05 00:30:26

问题


I am new to mingw/C++ and would like to compile and run the following code I found online:

#include <iostream>
using namespace std;

int main() 
{
    cout << "Hello, World!";
    return 0;
}

Unfortunately, running a g++ helloworld.cpp -o helloworld.exe throws the following error:

In file included from c:\mingw\include\_mingw.h:73,
                 from c:\mingw\include\wchar.h:53,
                 from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\cwchar:44,
                 from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\postypes.h:40,
                 from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\iosfwd:40,
                 from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ios:38,
                 from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ostream:38,
                 from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\iostream:39,
                 from helloworld.cpp:1:
c:\mingw\include\w32api.h:59:10: fatal error: sdkddkver.h: No such file or directory
 #include <sdkddkver.h>
          ^~~~~~~~~~~~~
compilation terminated.

I have the impression this is related to Windows SDK and triggered by #include <iostream>. What is <iostream>, why is it important here and how can I get it to compile with g++?

EDIT g++ version information

D:\TEMP\mingw_example>g++ --version
g++ (MinGW.org GCC-8.2.0-5) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

来源:https://stackoverflow.com/questions/60399865/compiling-simple-hellow-world-with-mingw-g

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!