1

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.

1
  • 1
    Your makefile is wrong. It has no rule to build example. It is only being built as a side effect. Commented Apr 2, 2022 at 11:39

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

4 Comments

also, add -O0 flag that will add extra debug information.
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
You have an additional problem: there is extra space between client and .c in your Makefile.
It's definitely not the case that adding -O0 will add extra debug information. First the optimizer options do not add or remove debug info: they only control how much optimization the compiler does on the code (but it is true that the higher the optimization level, the trickier it can be to debug since the code being run looks less like the source code). Second there's no difference between using -O0 and not using any -Ox option at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.