I execute the above with root -l -q -b compile.C and I obtain the file d3pdGammaJetBalance_C.so. I gSystem->Load that file in my macro, optimizeCuts.C, and the macro runs.
So, it’s all fine, when I do this on my mac.
When I do exactly the same things on linux, it compiles, but when I try to run optimizeCuts.C it complains that it can’t find PtEtaCollection_h.so.
A patch to make it work in linux is to gSystem->Load() the helper functions explicitly, before I load the d3pdGammaJetAnalysis_C.so. That way it works.
I dug into what goes wrong in Linux, and I ran ldd on the d3pdGammaJetAnalysis_C.so file, to see this:
To compare, I do the same on my mac, where things work. (Mac OS replaces “ldd” with “otool -L”)
Obviously, the .so file I make on the mac has the other libraries correctly linked, which is not the case in linux.
The question is “why?”
Here is some potentially helpful info:
Mac ROOT version: 5.26/00 14 December 2009
Linux ROOT version: Version 5.26/00b 9 February 2010
‘AddIncludePath’ only affect where to look for include files (i.e. for #include), the value that you pass there are most often different from the location of the library (i.e. usually myproject/include vs myproject/lib where we can not guess the ‘include’ and ‘lib’ part since they are only ‘convention’).
The different between linux and mac is in the way the linker records the library filename. On linux it records only the file name while on MacOS it records both the filename and its location and … thus can find it without help. On linux you must pass (via LD_LIBRARY_PATH for example) the location of the library.