Compillation of macros and shared libraries

This is a dummy version of the problem (using ROOT version 6.24/09):
I would like to create a shared library (dummy.cc):

#ifdef SUM0
    int sum0(int x){return x+0;}
#endif

int sum1(int x){return x+1;}

This can be done (see manual/root_macros_and_shared_libraries/) through a ROOT shell using the Load directive

root [0] .L dummy.cc++

Of course this only compiles the sum1 function as SUM0 is not defined.

Is it possible to activate the SUM0 block?
In fact it is but I am not sure if this is the expected behaviour…

root [0] gSystem->AddIncludePath("-DSUM0")
root [1] .L dummy.cc++

Welcome to the ROOT forum.

If the method you are using works why not using it ? May be have a look at CompileMacro, it seems that’s what you are looking for.

Thanks for the response.
Sure it works, but I would have expected AddIncludePath to be used to add only include paths, thus adding -I flag.
From the reference you are pointing out, I have also tryed
gSystem->SetMakeExe("g++ -Wall -fPIC $IncludePath $SourceFiles -o $ExeName $LinkedLibs -DSUM0")
but the -DSUM0 flags is not being obeyed.

Hi,

This is really for historical reasons - people used AddIncludePath() to pass extra flags and now we have to support it :slight_smile:

You want to use TSystem::SetMakeSharedLib() not SetMakeExe().

Cheers, Axel

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.