Compile xgboost with debugging symbols

I am planning to write a custom loss function based on rank_obj.cc.

I need to compile the code with -g -ggdb flags to execute the code step by step. I tried

  1. cp make/config.mk to root directory
  2. set ADD_CFLAGS = -g -ggdb
  3. mkdir build; cmake …; make -j4

but gdb complains about debugging symbols not being found

I also tried copying config.mk to the build directory to see if it would be picked up by the Makefile that cmake generates, but that doesn’t help

What is the correct procedure?

Best,
ged

You can use CMake:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
make -j4
1 Like