Home | News | Documentation | Download

Root6 :: load macro with multiple functions defined


_ROOT Version: 6.16/00
_Platform: Fedora 30
_Compiler: 9.1.1


I have some headaches with running a macro that have multiple functions defined…
the error (after a succesful aclic compilation) is of the form of :
aliroot: symbol lookup error: /home.hdd/adrian/work/jets-work/test_pPb/EmcalJetCDF_C.so: undefined symbol: Z18CreateAlienHandlerPKcS0_jjS0_S0_S0

where CreateAlienHandler is a function with the following signature (and forward declared)
AliAnalysisAlien* CreateAlienHandler ( const char* gridMode, const char* tag, unsigned int nr_test_files = 20, unsigned int TTL = 43200 , const char* outdir = “output”, const char* subworkdir = “”, const char* extradirlvl = “”);

I tried to load the .so generated by aclic in rootlogon and it shows in ListLibraries but i have the same error
Is there a catch to this?
Thanks a lot!
Adrian

Hello @adrian_sev,

forward declaring is not enough. When you forward declare, everything that uses the function compiles, but to link, the function needs to be defined in a library that ROOT has seen (=loaded).

  • Where is it defined exactly?
  • Is this file being compiled/loaded, e.g. by typing .L <fileWithDefinition.cxx>+ or by being linked into a library that’s being loaded?

Hi! It is just a macro that i run with root macro.C and it has multiple other functions… the thing is that when i chose another code path (that does not include this function) it works (so the other functions are found and used)
this is the macro EmcalJetCDF.C and i run it like this runGrid.sh

You are not forward-declaring what you define:
Fwd decl:

AliAnalysisAlien* CreateAlienHandler ( const char* gridMode, const char* tag, unsigned int nr_test_files, unsigned int TTL,
const char* outdir, const char* subworkdir, const char* extradirlvl ) {

Definition:

AliAnalysisAlien* CreateAlienHandler ( const char* gridMode, const char* tag, unsigned int nr_test_files, unsigned int TTL,
const char* outdir, const char subworkdir, const char* extradirlvl ) {

Check the type of subworkdir.

You have a bug in the CreateAlienHandle definition. There should be “const char *subworkdir” instead of “const char subworkdir”.

Thanks a lot!! By the way, how did you sow this? Just with optical recognition (and experience) or was something in the error that hinted towards the mismatch of the signatures?