Hello,
I need to be able to work with 2 versions of libstdc++.so simultaneously. In a command line I could do (i.e. compile a program with gcc-4.9.3 and link against a library which requires a newer version of libstdc++.so than the one supplied with gcc-4.9.3):
$ g++ -v
...
gcc version 4.9.3 (GCC)
$ g++ ... -L$HOME/bin/gcc-5.4.0/lib64 \
-Wl,-rpath=$HOME/bin/gcc-5.4.0/lib64 \
-L/path/to/library/compiled/with/gcc5 -lXXX \
-Wl,-rpath=/path/to/library/compiled/with/gcc5 \
-o program program.C
$ ./program
# nice result
and it works. But in Cling I try to do:
const TString libDir = "/path/to/library/compiled/with/gcc5";
const TString gcc5LibDir = "$HOME/bin/gcc-5.4.0/lib64";
gSystem->AddLinkedLibs(Form("%1$s/libXXX.so -Wl,-rpath=%1$s", libDir.Data()));
gSystem->AddLinkedLibs(Form("%1$s/libstdc++.so -Wl,-rpath=%1$s", gcc5LibDir.Data()));
.x program.C+
and it gives me
cling::DynamicLibraryManager::loadLibrary(): $HOME/bin/gcc-4.9.3/lib64/libstdc++.so.6: version `CXXABI_1.3.9’ not found (required by /path/to/library/compiled/with/gcc5/libXXX.so)
If I start ROOT like so:
env LD_LIBRARY_PATH=$HOME/bin/gcc-5.4.0/lib64:$LD_LIBRARY_PATH root.exe -b -l
then the above problem does not appear.
Question: could you please let me know what I could do right inside a ROOT session to be able to run .x program.C+
afterwards? I.e. I do not want to start ROOT in an unusual way and instead want to put any required commands into my macro. Somehow, I need to tell Cling where to search for a libstdc++.so with `CXXABI_1.3.9’.
The following ideas did not work for me:
* gSystem->Load(Form("%s/libstdc++.so", gcc5LibDir.Data())); // load error = 1
* const Char_t * const evLDLP = gSystem->Getenv("LD_LIBRARY_PATH");
gSystem->Setenv("LD_LIBRARY_PATH", Form("%s:%s", gcc5LibDir.Data(), evLDLP));
What is interesting is that the needed library is loaded but Cling still does not see it:
cling::DynamicLibraryManager::loadLibrary():
$HOME/bin/gcc-4.9.3/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not
found (required by /path/to/library/compiled/with/gcc5/libXXX.so)
root [2] gSystem->ListLibraries()
Loaded shared libraries
=======================
$HOME/bin/gcc-5.4.0/lib64/libstdc++.so
/path/to/library/compiled/with/gcc5/libXXX.so
...
Changing PATH
or LD_LIBRARY_PATH
in ~/.bashrc is not an option - the used compiler has to stay the same.
Thank you very much for your help!