0

My makefile looks like that and it works but for the valgrind bit. What do I do wrong?

all: main

main: main.o tree.o list.o
gcc -o main main.o tree.o list.o

main.o: main.c
gcc -Wall -Wextra -g -std=c11 -O2 -c main.c

tree.o: tree.h tree.c
    gcc -Wall -Wextra -g -std=c11 -O2 -c tree.c

list.o: list.c list.h
    gcc -Wall -Wextra -g -std=c11 -O2 -c list.c

clean:
    rm *.o main

valgrid:
    valgrind ./main

Error is: makefile:19: *** missing separator. Stop.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
GraphLearner
  • 179
  • 1
  • 2
  • 11
  • What's the error you're getting with the `valgrind` target? – Stephen Newell Mar 17 '18 at 16:21
  • 1
    Refer this https://stackoverflow.com/questions/16931770/makefile4-missing-separator-stop – Arpan Sarkar Mar 17 '18 at 16:34
  • Spell `valgrind` consistently — `valgrid` is a different program. Make the `valgrind` target depend on `main` (you probably don't want to waste your time running `valgrind` on an out of date program): `valgrind: main`. You're going to want to add flags to Valgrind, at least on occasion. Use macros: `VALGRIND = valgrind` and `VALGRIND_FLAGS =` (nothing by default), and then the command should become `${VALGRIND} ${VALGRIND_FLAGS} ./main`. That allows you to run Valgrind with different flags without editing the makefile. – Jonathan Leffler Mar 17 '18 at 17:35

0 Answers0