I have a macro to solve differential equations using the RK4 method in the GSL libraries.
At the top of my .cpp file I have
R__LOAD_LIBRARY(gsl);
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_odeiv2.h>
with the other libraries that I need.
If type .x mycode.cpp, and .L mycode.cpp my code works and I get good results. However, if I try to compile with .L mycode.cpp+ I get the next error message:
Info in TUnixSystem::ACLiC: creating shared library /mnt/e/user/Desktop/mycode_cpp.so
cling::DynamicLibraryManager::loadLibrary(): /mnt/e/user/Desktop/mycode_cpp.so: undefined symbol: gsl_odeiv2_step_rk4
/mnt/e/user/Desktop/mycode_cpp_ACLiC_dict.o: In function main': mycode_cpp_ACLiC_dict.cxx:(.text+0x1985): undefined reference to gsl_odeiv2_step_rk4’
mycode_cpp_ACLiC_dict.cxx:(.text+0x19a8): undefined reference to gsl_odeiv2_step_alloc' mycode_cpp_ACLiC_dict.cxx:(.text+0x19d6): undefined reference to gsl_odeiv2_control_y_new’
mycode_cpp_ACLiC_dict.cxx:(.text+0x19ec): undefined reference to gsl_odeiv2_evolve_alloc' mycode_cpp_ACLiC_dict.cxx:(.text+0x24c2): undefined reference to gsl_odeiv2_evolve_apply’
mycode_cpp_ACLiC_dict.cxx:(.text+0x27f6): undefined reference to gsl_odeiv2_evolve_free' mycode_cpp_ACLiC_dict.cxx:(.text+0x2805): undefined reference to gsl_odeiv2_control_free’
mycode_cpp_ACLiC_dict.cxx:(.text+0x2814): undefined reference to `gsl_odeiv2_step_free’
collect2: error: ld returned 1 exit status
I believe those gsl functions are defined in gsl_odeiv2.h, so I don’t understand this error.
I added R__LOAD_LIBRARY(libgsl) at the top of my macro, and I keep getting the same error. However, if I type this in a root command line and then compile, it works. How is this possible?