ZackRyan
ZackRyan

Reputation: 39

C Program Debugging: Cannot get Makefile to work with GDB

I have a makefile as follows:

CC=gcc
CFLAGS=-g -Wall -Wextra
PTHREADS=-lpthread

all: client.o threadpool.o
                $(CC) $(CFLAGS) -o example client.o threadpoool.o $(PTHREADS)

client.o: client .c
           $(CC) $(CFLAGS) -c client.c $(PTHREADS) 

threadpool.o: threadpool.c threadpool.h
           $(CC) $(CFLAGS) -c client.c $(PTHREADS) 

clean: 
           rm -rf *.o
           rm -rf example

However, when I run the makefile and then try and load example into GDB like so:

$ make
$ gdb ./example

...it says no debugging symbols found. Can anyone help me understand this? It is my first time attempting to use GDB and am very new to C programming in general. Thank you.

I tried to add the -g and -Wextra flags but this did not work.

Upvotes: 1

Views: 104

Answers (1)

ZackRyan
ZackRyan

Reputation: 39

Running make clean and then re running make and loading it into gdb worked.

Upvotes: 1

Related Questions