Pilfer Ahn
Pilfer Ahn

Reputation: 91

How could I compile cpp file in powershell without Visual Studio?

Could I compile the cpp file without Visual Studio or Eclispe? Or do i must install ?

if possible, what is the command line in powershell? I remember, I used to type gpp (somethings here) when I used the mac but I don't know the way to compile in window.

Upvotes: 0

Views: 2708

Answers (1)

jacob
jacob

Reputation: 1630

You can install g++ in Windows, too. On Mac, it was installed from its software repositories. In Windows, there are several distributions of that compiler, often bundled with some basic Unix-like environment, e.g. MSYS2, Cygwin, or MinGW (consult Google for details on these). You just need to choose and install one of them.

An easy way how to start is to download and unpack the last version of MinGW-w64. You will find the compiler g++.exe inside. Then, in PowerShell, simply use the full path to the executable, for example something like

C:\mingw64\bin\g++.exe prog.cpp -o prog.exe

depending on where you unpacked the package.

Note that you will need to copy a few DLLs (libstdc++.dll, maybe others, depending on features that you use) from the directory with g++.exe into the directory with your compiled program to be able to execute it.

Upvotes: 1

Related Questions