我有一个Makefile作为:

CC = g++

#SNAP DEFINITIONS
SNAP = Snap-2.3
SNAPCORE = $(SNAP)/snap-core
GLIB = $(SNAP)/glib-core
CPPFLAGS += -I $(GLIB) -I $(SNAPCORE)

pagerank_debug.o: pagerank.cpp
        $(CC) $(CPPFLAGS) -c pagerank.cpp -o pagerank_debug.o

pagerank.o: pagerank.cpp
    $(CC) $(CPPFLAGS) -c pagerank.cpp

pr_debug: pagerank_debug.o $(SNAPCORE)/Snap.o
    $(CC) -g pagerank_debug.o $(SNAPCORE)/Snap.o -o prd

pr: pagerank.o $(SNAPCORE)/Snap.o
    $(CC) pagerank.o $(SNAPCORE)/Snap.o -o pr

.PHONY: clean
clean:
    rm *.o prd


执行make pr_debug时,代码编译为:

g++ -I Snap-2.3/glib-core -I Snap-2.3/snap-core -c pagerank.cpp -o pagerank_debug.o
g++ -g pagerank_debug.o Snap-2.3/snap-core/Snap.o -o prd


我没有看到任何调试符号。潜在的问题是什么?

更新的Makefile(仍然不起作用)

#SNAP DEFINITIONS
SNAP = /Users/myth/Snap-2.3
SNAPCORE = $(SNAP)/snap-core
GLIB = $(SNAP)/glib-core
INCLUDE += -I $(SNAPCORE) -I $(GLIB)
CPPFLAGS += -c -g -Wall

pagerank_debug: pagerank_undirected.cpp
        g++ $(INCLUDE) $(CPPFLAGS) pagerank_undirected.cpp -o pagerank_undirected.o

pr_debug: pagerank_debug
        g++ -g pagerank_undirected.o $(SNAPCORE)/Snap.o -o pru

.PHONY: clean all

all: pr_debug
clean:
    rm *.o pru

最佳答案

编译时应添加-g标志,因此将其添加到CPPFLAGS

CPPFLAGS += -I $(GLIB) -I $(SNAPCORE) -g

关于c++ - Make不生成调试符号,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28229960/

10-11 17:53