Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debug makefile project in eclipse

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?

like image 612
RandyTek Avatar asked Dec 29 '11 02:12

RandyTek


1 Answers

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
like image 62
MestreLion Avatar answered Sep 19 '22 10:09

MestreLion