2.2.2.1 : To enable the debugging symbols



The first thing to do is to enable the debugging symbols in the compilation of our program.

So, we have to change the CMakeLists.txt file to enable these debugging symbols.



This is done with the function add_definitions. You can do :

1
add_definitions(-O3 -g)


if you still want good optimisations, or :

1
add_definitions(-Og)


if you want to keep some optimisations.

So, your CMakeLists.txt file will looks like :



1
2
3
4
5
6
project(HadamardProductMemoryLeak)
cmake_minimum_required(VERSION 3.0)

add_definitions(-O3 -g)

add_executable(hadamard_product_memory_leak main.cpp)


Then, we have to recompile your program :
1
2
3
4
5
make
Scanning dependencies of target hadamard_product_memory_leak
[ 50%] Building CXX object CMakeFiles/hadamard_product_memory_leak.dir/main.cpp.o
[100%] Linking CXX executable hadamard_product_memory_leak
[100%] Built target hadamard_product_memory_leak