Dinesh
Dinesh

Reputation: 16428

Compilation errors with Make File creation

While running my make file which is as follows,

../bin/output : ../lib/libfun.a ../obj/main.o
                gcc ../main.o -L ../lib/ -lfun -o $@
../lib/libfun.a : ../obj/file_write.o ../obj/error.o
                ar -rc $@ $^
../obj/main.o   : ../src/main.c
                gcc -c $^ -o $@ -I ../include
../obj/file_write.o     : ../src/file_write.c
                gcc -c $^ -o $@ -I ../include
../obj/error.o  : ../src/error.c
                gcc -c $^ -o $@ -I ../include

I am getting error like

make: Warning: File `makefile' has modification time 2.2e+03 s in the future
ar -rc ../lib/libfun.a ../obj/file_write.o ../obj/error.o
ar: ../lib/libfun.a: No such file or directory
make: *** [../lib/libfun.a] Error 1

and sometimes

"* missing separator (did you mean TAB instead of 8 spaces?). Stop"

Why is this happening? I gave correct Target,Pre-Requests and Command values whichever needed. Whats wrong in this?

Upvotes: 0

Views: 1708

Answers (1)

Mat
Mat

Reputation: 206659

For the first error, make sure the ../lib directory exists before trying to create a library in it. ar will return that error if the path doesn't exist.

For the second make syntax is strict: the commands after a target must be indented with a tab, not spaces.

target: deps
        command
#  ^ this here needs to be a tab character, not spaces

Upvotes: 2

Related Questions