So I tried to recompile one of my projects from a few weeks ago and to my surprise I keep receiving an error one on it. I used MinGW to compile it originally and Eclipse CDT. I have -Wall flag enabled on GCC so I assumed if it was a problem with the code I would have a more useful information than a make error 1 being thrown. As such, I suspect that the issue could lie in how I formatted the make file. Luckily, I did compile the project when I push the commits last time and the binaries are still in the repo. Nevertheless, I would appreciate some help so that I can continue to improve the project.
Edit: when I do -all, it just refuses to compile.
Here is the makefile. I hope it is a simple as me following some incorrect syntax:
CC=gcc -I../Include -L..\Lib
override CFLAGS+=-Wall -O3 #$(shell pkg-config --cflags fftw3)
#override LDFLAGS+=#$(shell pkg-config --libs fftw3 glib-2.0) -lm
.PHONY: all clean
all: lvdoenc lvdodec
lvdoenc: lvdoenc.o lvdomain.o
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -I../Include -L../Lib -lfftw3
lvdodec: lvdodec.o lvdomain.o
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -I../Include -L../Lib -lfftw3
%.o: %.c
$(CC) -c $(CFLAGS) -o $@ $^
lvdoenc.c: lvdocommon.h
lvdodec.c: lvdocommon.h
clean:
rm -f lvdoenc lvdodec lvdomain.o lvdoenc.o lvdodec.o
Here is a link to my repo: https://github.com/Skylion007/LVDOWin
Update: Using some of the answers I have confirmed that it is GCC that is exiting with an error 1 and I cannot figure out why.
Update2: It's not printing anything to syserr.
Without a transcript of make's output, when you run it, I can't see why GCC should fail silently, but I can see at least two problems with your makefile:
Since you state that you are using MinGW, your target platform must be MS-Windows, on which executable files should be qualified by a
.exe
extension; thus, yourall: lvdoenc lvdodec
rule is malformed; it should, at the very least beall: lvdoenc.exe lvdodec.exe
[1], (or better, for portabilityall: lvdoenc$(EXEEXT) lvdodec$(EXEEXT)
, where you defineEXEEXT = .exe
for Windows, and leaveEXEEXT
undefined, or defined to be nothing, for platforms which don't require the extension).Your two rules
lvdoenc.c: lvdocommon.h
andlvdodec.c: lvdocommon.h
are obviously incorrect; the.c
files don't depend on the.h
, but their respective.o
files do. Thus, these two rules should belvdoenc.o: lvdocommon.h
andlvdodec.o: lvdocommon.h
respectively.[1] Of course, you then also need to correctly refer to these two "goals" respectively, as
lvdoenc.exe
andlvdodec.exe
, (orlvdoenc$(EXEEXT)
andlvdodec$(EXEEXT)
), consistently, throughout the makefile.There are a few other constructs, within your makefile, which I consider questionable:
CC
shouldn't really be defined, with the-I../Include
or-L..\Lib
, (and why inconsistently/
in the former, but\
in the latter? Both should be/
). Conventionally,-I ...
belongs inCPPFLAGS
, and-L ...
inLDFLAGS
, with bothCFLAGS
andCPPFLAGS
passed to the compiler, and normally all ofCFLAGS
,CPPFLAGS
, andLDFLAGS
passed to the compiler driver, when invoking the linker, (although, as others have noted in comments, the-I ...
settings are strictly necessary when compiling.c
to.o
, while the-L ...
settings are required only in the linking phase).