Stephen Smith
Stephen Smith

Reputation: 513

MinGW won't compile, Error 1

Making a simple hello world app in c++, but it won't compile. I have the folder C:\WiiGames\e3\ with the files main.cpp and Makefile. My makefile is:

build: main.cpp
    C:/MinGW/bin/g++.exe main.cpp -o e3.exe

My error is:

C:\WiiGames\e3>make build
C:/MinGW/bin/g++.exe main.cpp -o e3.exe
make: *** [build] Error 1

C:\WiiGames\e3>

Any help would be greatly appreciated.

My code:

#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <cstdlib>
#include <time.h>

int main() {
    printf("Hello World!");
}

g++ -v:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.2 (GCC)

Upvotes: 1

Views: 18012

Answers (3)

vesperto
vesperto

Reputation: 883

Yes, it's an old question. These are some solutions i came across (YMMV a lot):

Check if your paths start with c:/ as opposed to /c/ or vice-versa.

Check if you're running in the right shell, i.e., one of:

  • c:\msys64\msys2_shell.cmd -mingw32
  • c:\msys64\mingw32.exe
  • c:\msys64\usr\bin\bash.exe

which may differ if used within an IDE.

Upvotes: 0

01100110
01100110

Reputation: 2344

What happens when you run g++.exe main.cpp -o e3.exe on the command line directly? If nothing happens, is g++ in your path? I'd start by making sure that g++ is setup and in your path.

Upvotes: 1

Wayne Tanner
Wayne Tanner

Reputation: 1356

Make sure it is a tab rather than spaces in the make file before the c:/mingw... Line. It looks like it is make giving the error, not g++.

Upvotes: 1

Related Questions