Question

I have:
fileMainProgram.cpp
fileClassImplementation.cpp
fileClass.h
makefile

in a directory.
Ran cmd and typed

              g++ -make -f makefile

got this message after tinkering with it for a while (change file name/extension, tried without -f, used gcc instead of g++, etc)


C:\miscprograms\Dropbox\box\Dropbox\c++\etextbook\e12\progec12\pe1c12romanNumeral>g++ -make -f makefile

c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe:makefile.tx t: file format not recognized; treating as linker script c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe:makefile.tx t:1: syntax error collect2: ld returned 1 exit status


This is the makefile, (tried to delete the lines inbetween targets and actions, tried using automatic variables, etc,

I tried to compile the program as

                                      g++ -c fileClassImplementation.cpp

                           then

                                      g++ fileClassImplementation.o fileMain.cpp

to get an executable and it works fine.


 all: a

 a: romanNumeralMain.o romanNumeralImp.o
 [1 tab]g++ romanNumeralMain.o romanNumeralImp.o -o a

 romanNumeralMain.o: romanNumeralMain.cpp 
        g++ -c romanNumeralMain.cpp

 romanNumeralImp.o: romanNumeralImp.cpp
        g++ -c romanNumeralImp.cpp

 clean:
        rm romanNumeralImp.o romanNumeralMain.o a

Ran the whole thing on C4droid for my samsung phone and worked fine as is.
Doesn not work on my Windows7 laptop.

Was it helpful?

Solution

What you appear to have is a GNU Makefile, suitable for running GNU Make. Windows doesn't come with GNU Make, so you'll need to download it yourself.

It appears you've already downloaded MingW, try running the mingw32-make command to execute your makefile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top