Compiling external programs and +g

I have an external (pure c++, no ROOT) program that uses the GSL libraries and I would like to be able to call this from within ROOT after something like:

A toy example such as

#include <iostream>
#include <gsl/gsl_complex_math.h>

class myClass {
  gsl_complex z;

int main() {
  myClass a;
  a.z = gsl_complex_rect(1.0, 0.0);
  std::cout << GSL_REAL(a.z) << " + " << GSL_IMAG(a.z) << " i" << std::endl;
  return 0;

Runs fine on the terminal, but fails to compile in ROOT. That is .L with +g fails. The error message is:

I’ve also tried:

gSystem -> AddDynamicPath(".")
gSystem -> Load("myCppProg.o")

which gives the error message

(I’ve check and the pwd does contain a file myCppProg.o)

Can someone point me in the right direction?

Thanks in advance!


This has nothing to do with debug symbols. Just like when compiling your macro with a compiler where you had to add a link dependency on libgsl (e.g. -lgsl somewhere), you need to load that library in CINT, e.g.

root [1] gSystem.Load("/usr/lib/libgsl")
root [2] .L myROOTprog.cpp+g