C计划调试:无法使Makefile与GDB一起工作
我有一个makefile,如下所示:
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
但是,当我运行makefile然后尝试将示例加载到GDB中时:
$ make
$ gdb ./example
... ...没有发现调试符号。谁能帮我理解这一点?这是我第一次尝试使用GDB,并且通常是C编程的新手。谢谢。
我尝试添加-g和-wextra标志,但这无效。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
运行 make clean,然后重新运行 make 并将其加载到 gdb 中即可。
Running make clean and then re running make and loading it into gdb worked.