Reputation: 184
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.
Upvotes: 7
Views: 9787
Reputation: 1361
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
).
Upvotes: 4
Reputation: 166
I've had the same issue and, after running it with the traditional batch console instead of powershell, I noticed a dll
was missing. The dll error won't pop up in the powershell command line (god only knows why).
In my case it was libisl-15.dll
, but it may be different on your PC.
Hope this helps someone in the world!
Upvotes: 11
Reputation: 6407
Command
g++ HelloWorld.cpp -o HelloWorld.exe
does not execute propgam, it just build executable file HelloWorld.exe
.
So, after g++ HelloWorld.cpp -o HelloWorld.exe
check the appearance of HelloWorld.exe
file. If it is, just run it like:
.\HelloWorld.exe
Upvotes: 3