在eclipse中调试makefile项目

Ran*_*Tek 6 c++ eclipse eclipse-cdt

我在eclipse中导入了一个"现有代码作为makefile项目"项目.我想在eclipse中调试,比如我可以创建断点或者单步执行代码.如果我直接调试项目,eclipse说XXX.cpp没有源代码,所以我无法调试.

我应该如何在eclipse中更改makefile进行调试?

Mes*_*ion 13

只需确保您的Makefile目标不会删除可执行文件,它包含调试符号.

这意味着该gcc行不得包含-s,它应该包含-g

这种简单的Makefile的一个例子是:

TARGET   = YOUR_EXECUTABLE_NAME
SOURCES  = $(shell echo *.c)
HEADERS  = $(shell echo *.h)

prefix   = /usr/local
bindir   = $(prefix)/bin

all: $(TARGET)

debug: CFLAGS += -g -O0 -Wall -Wextra
debug: $(TARGET)

$(TARGET): $(SOURCES) $(HEADERS)
    $(CC) $(CFLAGS) $(DEFS) -o $(TARGET) $(SOURCES) $(LIBS)

install: $(TARGET)
    install -s -D $(TARGET) $(DESTDIR)$(bindir)/$(TARGET)

uninstall:
    rm -f $(DESTDIR)$(bindir)/$(TARGET)

clean:
    rm -f $(TARGET)

distclean: clean

.PHONY : all debug install uninstall clean distclean
Run Code Online (Sandbox Code Playgroud)