-lm Not linking math library in makefile
The command in the makefile:
gcc -o gensine encode.o gensine.o write.o helper.o -lm
does not match the command you printed at the end:
cc gensine.c -o gensine
Notice also that there is no -lm
Note that make
knows how to make object files so you don't need most of the makefile. Try this (remember to indent with TABs):
.PHONY : all cleanall = gensine infoCFLAGS =-WallLIBS = -lmgensine: encode.o gensine.o write.o helper.o gcc -o $@ $^ $(LIBS)info: read.o info.o decode.o helper.o gcc -o $@ $^ $(LIBS)cs229towav: write.o read.o cs229towav.o decode.o encode.o helper.o gcc -o $@ $^ $(LIBS)clean: rm -rf *.o gensine info cs229towav
Edit:
Boddie, note that your confusion arose because you thought the makefile was a script - ie. that you were running your script named make
when you typed make gensine
. In fact make
is a command like gcc
somewhere else in the filesystem (on Linux etc, type which make
to see where it is). The make
command expects to find an input file containing build rules called makefile
or Makefile
in the current directory. If it doesn't find that file it uses some built-in rules instead - hence the cc gensine.c -o gensine
which is nowhere in your makefile. If you want to, you can tell make
the name of the makefile (so that it doesn't use the default names) with the -f
switch, as @DanielFischer described in the comments.