g++ does not make any file or give any output

Viewed 6021

I've just started using g++, downloading the latest version from the site, and I've made a simple HelloWorld program.

#include <iostream>
using namespace std;
int main()
{
  cout << "Hello World!" << endl;
  return 0;
}

When I try to execute using the powershell window and g++, in the right directory, I use the following command:

g++ HelloWorld.cpp -o HelloWorld.exe

This gives no output and makes no files. I used the -v command as per some other answer I read on the site and it gave me this. I don't know how to proceed and execute my program.

OUTPUT After DIR

3 Answers

The accepted answer from Didier helped me solve the same problem. In my case HelloWorld.exe could use printf without any problem, but std::cout produced no output in the Windows console.

The HelloWorld.exe can be inspected by dumpbin.exe /imports HelloWorld.exe (dumpbin.exe is distributed with Visual Studio 2019). In my case this showed a dependency on MinGW's libstdc++-6.dll, which again is dependent on MinGW's libgcc_s_seh-1.dll and libwinpthread-1.dll.

Bottom line: the solution is to add the MinGW bin folder to your path, like suggested by Carucel. When the path is correctly configured you can use the 'where' command (from CMD) to verify the needed DLLs can be found (e.g.: where libstdc++-6.dll).

Related