c++linuxmakefilegnu-make

g++ does not produce debug symbols


I am learning linux, and my first step is to adapt my project for running on linux. Here is simple makefile (in educational purposes mostly), which generates out file:

#------------------------BUILD VARIABLES-----------------------------
#   Directories, containing headers
INCLUDE_DIR = ../Include/
#   Output directory which will contain output compiled file
OUTPUT_DIR = ../Bin/Debug/

SOURCES = EngineManager.cpp Geometry.cpp Main.cpp Model.cpp \
      Shaders.cpp TGAImage.cpp 

HEADERS = EngineManager.h Geometry.h Line.h Model.h Shaders.h \
      TGAImage.h Triangle.h

#------------------------BUILD_RULES---------------------------------
TinyRenderBuilding : $(addprefix $(INCLUDE_DIR), $(HEADERS)) $(SOURCES)
    mkdir -p  $(OUTPUT_DIR)
    g++ -std=c++14 -o $(OUTPUT_DIR)TinyRender.out -g -I$(INCLUDE_DIR) $(SOURCES)

I cannot understand, why does g++ not generate debug symbols? -g option is presented


Solution

  • According to your makefile g++ should produce debug symbols (-g option is presented). To confirm this you can run file on resulting binary:

    $ file a.out
    a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=9fe588c18099ef418daf288931bb033cc287922e, with debug_info, not stripped
    

    (Note with debug_info string in output)