I have import a "existing code as makefile project" project in eclipse. I want to debug in eclipse such as I can make breakpoint or step in step out the code. If I directly debug the project the eclipse say there are no source code for XXX.cpp, so that I can not debug.
How should I change the makefile to debug in the eclipse?
Just make sure your Makefile target does not strip the executable, and it includes debug symbols.
That means the gcc
line must not contain -s
, and it should contain -g
An example of such simple Makefile would be:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With