Cannot get makefile to produce gmon.out
c, gcc, gprof, makefile
Solution
The gmon.out file is not created until you run your program.
The -pg switch just adds the calls to create the gmon.out file when the program is run.
Run your program:
fs
Then run gprof:
gprof
Read the man page for gprof
Problem
I am trying to profile my code since I can't figure out what is slowing it down. I have the following makefile: ``` CXX=gcc RM=rm -f CFLAGS=-pg -DNDEBUG -O3 -g3 -O0 -D_FILE_OFFSET_BITS=64 LDFLAGS=-pg -lpthread `pkg-config fuse --cflags --libs` EXEC = fs SRCS=$(shell echo *.c) OBJS=$(subst .c,.o,$(SRCS)) all: $(EXEC) $(EXEC): $(OBJS) $(CXX) $(LDFLAGS) -o $(EXEC) $(OBJS) %.o: %.c $(CXX) $(CFLAGS) -c -o $@ $^ clean: $(RM) *.o $(RM) $(EXEC) ``` which produces this output: ``` gcc -pg -DNDEBUG -O3 -g3 -O0 -D_FILE_OFFSET_BITS=64 -c -o datablock.o datablock.c gcc -pg -DNDEBUG -O3 -g3 -O0 -D_FILE_OFFSET_BITS=64 -c -o disk.o disk.c gcc -pg -DNDEBUG -O3 -g3 -O0 -D_FILE_OFFSET_BITS=64 -c -o fsinterface.o fsinterface.c gcc -pg -DNDEBUG -O3 -g3 -O0 -D_FILE_OFFSET_BITS=64 -c -o inode.o inode.c gcc -pg -DNDEBUG -O3 -g3 -O0 -D_FILE_OFFSET_BITS=64 -c -o main.o main.c main.c:19: warning: initialization from incompatible pointer type gcc -pg -DNDEBUG -O3 -g3 -O0 -D_FILE_OFFSET_BITS=64 -c -o mkfs.o mkfs.c gcc -pg -lpthread `pkg-config fuse --cflags --libs` -o fs datablock.o disk.o fsinterface.o inode.o main.o mkfs.o [root@ip-10-2-176-50 fusefilesystemclean]# gprof fs gmon.out: No such file or directory ``` and I can't seem to get a gmon.out file to be produce. I am not very good wuth Makefiles. Can someone help me? Thanks.