I would like to add a debugging feature in a makefile (flag -ggdb of g++). A quick and dirty solution worked only partially. Debugging was possible but the gnu debugger reported that no debugging symbols found. That was due to the linking of the files which was done separately from the final compilation. The makefile first generates single object files from all source code files and I do not know how to include the flag -ggdb flag in this compilation. Can somebody tell me what I need to do to include the -ggdb option in the first compilation of the source files? Ideally the proper way to do that? Here is the makefile content:
CC=g++ # define the compiler to use
TARGET=greens# define the name of the executable
SOURCES=analyzenet.cpp bicgstab.cpp blood.cpp cmgui.cpp contour.cpp contr_lines.cpp contr_shade.cpp convect.cpp eval.cpp gaussj.cpp greens.cpp histogram.cpp initgreens.cpp input.cpp ludcmp.cpp main.cpp nrutil.cpp outboun.cpp picturenetwork.cpp postgreens.cpp putrank.cpp setuparrays0.cpp setuparrays1.cpp setuparrays2.cpp testconvect.cpp tissrate.cpp # list source files
CFLAGS=-O3
LFLAGS=-Wall -lm -std=c++17
# define list of objects
OBJSC=$(SOURCES:.c=.o)
OBJS=$(OBJSC:.cpp=.o)
# the target is obtained linking all .o files
# for mac: remove -lstdc++fs tag following $(TARGET)
all: $(SOURCES) $(TARGET)