iSavo
iSavo

Reputation: 1

MingGW C++ compiler does not work

I am trying to install C and C++ compiler on Windows 8. I have already installed MinGW, downloaded and installed mingw32-base and mingw32-gcc-g++ packages and the other required packages, added to the user environmet Path the string "C:\MinGW\bin", and I also tried following this guide

http://www.mingw.org/wiki/Getting_Started

so after installation I created a new file named "fstab" containing "C:\MinGW /mingw" in C:\MinGW\msys\1.0\etc because it was only present the file named "fstab.sample".

After all this I typed on cmd : gcc sample.cpp -o sample.exe and it doesn't work at all returning me an error: gcc: fatal error: no input files compilation terminated

But if I typed gcc --version it gives me gcc 4.9.3 etc... so the packages are installed but I can't compile any of my programs

Upvotes: 0

Views: 2564

Answers (3)

secretgenes
secretgenes

Reputation: 1290

It's a very common error when you are not in the current directory where your source files are residing.

So just navigate to the current directory and run the command it will compile the source code.

Upvotes: 0

Exceptyon
Exceptyon

Reputation: 1582

possibly some problem with folders. probably you are not compiling from source directory.

Check out this mingw distro by STL. It contains a few .bat files that open a cmd prompt with compiler in PATH. I use these for all my mingw installations. BAT files are to be placed in mingw folder:

mingwvars.bat

@echo.
@echo Setting up environment for using MinGW with GCC from %~dp0.
@set PATH=%~dp0bin;%PATH%

set_distro_paths.bat

@echo off
if not exist "%~dp0bin\gcc.exe" goto epicfail
if "%X_DISTRO%" == "nuwen" goto :eof
set X_DISTRO=nuwen
if exist "%~dp0git\cmd\git.exe" set PATH=%~dp0git\cmd;%PATH%
set PATH=%~dp0bin;%PATH%
goto :eof

:epicfail
color 4f
echo ERROR: You must run %~nx0 from the root of the distro.
echo        Don't copy or move this batch file.
title ERROR
goto :eof

open_distro_window.bat

@echo off
if not exist "%~dp0bin\gcc.exe" goto epicfail
if "%X_DISTRO%" == "nuwen" goto :eof
set X_DISTRO=nuwen
if exist "%~dp0git\cmd\git.exe" set PATH=%~dp0git\cmd;%PATH%
set PATH=%~dp0bin;%PATH%
goto :eof

:epicfail
color 4f
echo ERROR: You must run %~nx0 from the root of the distro.
echo        Don't copy or move this batch file.
title ERROR
goto :eof

Upvotes: 1

VictorC
VictorC

Reputation: 71

Are you in the correct directory in cmd when compiling?

You can navigate to the correct one with cd and check if your .cpp is there with ls

Upvotes: 1

Related Questions