|
List Info
Thread: RE: load a list of libs
|
|
| RE: load a list of libs |
  United States |
2008-03-10 10:47:54 |
> Hi Dario,
>
> this I know. But this command seems to load only one
library. Is there
> something like:
> root[] gSystem->LoadListOfLibs("-L/path_to_libs
-lApp1 -lApp2 -lApp3");
Yes, it does exist. Here you are
{
TString lPath = gSystem->GetDynamicPath();
lPath+= ":path_to_libs";
gSystem->SetDynamicPath((const char*)lPath);
const char *libs[] = { "App1",
"App2", "App3" };
for (int i = 0; i < sizeof(libs)/sizeof(char *); i++)
printf(" Loading %s %dn", libs[i],
gSystem->Load(libs[i]));
}
Hope this helps
Valeri Fine
---------------
Brookhaven National Laboratory
Upton, NY 11973, USA
Phone: +1 631 344 7806
Fax: +1 631 344 4206
E-mail: fine bnl.gov
> Thanks, Dmitry
>
> Dario Berzano ÐÉÛÅÔ:
> > On Mon, Mar 10, 2008 at 6:06 PM, Dmitry Naumov
<naumov nusun.jinr.ru>
> wrote:
> >
> >> Dear roottalk,
> >>
> >> is there an implemented way to load a list of
libraries made in the
> form:
> >> -L/path_to_libs -lApp1 -lApp2 -lApp3 ...
> >> from the root interpreter?
> >>
> >
> > Hi Dmitry,
> >
> > you can try
gSystem->Load("library_name"). The
documentation is
> > available here:
> >
> > http://root.cern.ch/root/html/TSystem.html#TSystem:Load
a>
> >
> > Regards,
> >
|
|
| RE: load a list of libs |
  Russian Federation |
2008-03-10 17:38:44 |
Hi Valeri,
thanks for your response. Well, this is again the same
gSystem->Load()
function. Certainly I could do this kind of loop...
The reason of my question is motivated by a simple idea. I
am using ROOT
VMC in my application. If I run it from the root interpreter
I use a macro
which loads several dozens of Geant4 libraries. From release
to release G4
merges/splits/renames some libraries and I have to follow
all these
developments in that macro. On the other hand G4 always
provides a nice
method similar to that in root-config. It can return me a
line with all
libraries like:
-lG4_lib1 -lG4lib2 ... -lG4libN
and like this for several dozens of libraries. Therefore I
though that it
would be nice if instead of using a macro which loads one by
one all the
libraries I would simply ask root to load everything in one
go. Well, one
can say, please, split the line and use again
gSystem->Load() substituting
-lG4_lib1 by libG4lib1.so (thus analyzing the string).
Certainly this is
possible and quite easy to realize, while it would be a sort
of
comfortable to be able to load everything just by a line
like:
gSystem->LoadListOfLibs("")
This is the point. Ok, if this is not possible I will
proceed with a
loop, thanks again, Dmitry
>> Hi Dario,
>>
>> this I know. But this command seems to load only
one library. Is there
>> something like:
>> root[]
gSystem->LoadListOfLibs("-L/path_to_libs -lApp1
-lApp2 -lApp3");
>
> Yes, it does exist. Here you are
>
> {
> TString lPath = gSystem->GetDynamicPath();
> lPath+= ":path_to_libs";
> gSystem->SetDynamicPath((const char*)lPath);
> const char *libs[] = { "App1",
"App2", "App3" };
> for (int i = 0; i < sizeof(libs)/sizeof(char *);
i++)
> printf(" Loading %s %dn", libs[i],
gSystem->Load(libs[i]));
>
> }
>
> Hope this helps
>
> Valeri Fine
> ---------------
> Brookhaven National Laboratory
> Upton, NY 11973, USA
> Phone: +1 631 344 7806
> Fax: +1 631 344 4206
> E-mail: fine bnl.gov
>> Thanks, Dmitry
>>
>> Dario Berzano �����:
>> > On Mon, Mar 10, 2008 at 6:06 PM, Dmitry Naumov
<naumov nusun.jinr.ru>
>> wrote:
>> >
>> >> Dear roottalk,
>> >>
>> >> is there an implemented way to load a
list of libraries made in the
>> form:
>> >> -L/path_to_libs -lApp1 -lApp2 -lApp3 ...
>> >> from the root interpreter?
>> >>
>> >
>> > Hi Dmitry,
>> >
>> > you can try
gSystem->Load("library_name"). The
documentation is
>> > available here:
>> >
>> > http://root.cern.ch/root/html/TSystem.html#TSystem:Load
a>
>> >
>> > Regards,
>> >
>
|
|
| RE: load a list of libs |
  Denmark |
2008-03-11 03:11:35 |
Hi,
On Mon, 2008-03-10 at 11:47 -0400, Fine, Valeri wrote:
> > Hi Dario,
> >
> > this I know. But this command seems to load only
one library. Is there
> > something like:
> > root[]
gSystem->LoadListOfLibs("-L/path_to_libs -lApp1
-lApp2 -lApp3");
>
> Yes, it does exist. Here you are
>
> {
> TString lPath = gSystem->GetDynamicPath();
> lPath+= ":path_to_libs";
> gSystem->SetDynamicPath((const char*)lPath);
> const char *libs[] = { "App1",
"App2", "App3" };
> for (int i = 0; i < sizeof(libs)/sizeof(char *);
i++)
> printf(" Loading %s %dn", libs[i],
gSystem->Load(libs[i]));
>
> }
How about something like
#include <sstream>
void HandleLinkLine(const char* str)
{
std::stringstream s(str);
while (!s.eof()) {
std::string comp;
s >> comp;
if (s.bad()) break;
if (comp[0] != '-') {
Warning("LoadLibraryList",
"Unknown component %s in %s", comp.c_str(), str);
continue;
}
std::string dir_or_file =
comp.substr(2,comp.size()-2);
if (comp[1] == 'L') {
std::string path =
gSystem->GetDynamicPath();
path += ':'; path += dir_or_file;
gSystem->SetDynamicPath(path.c_str());
}
else if (comp[1] == 'l') {
std::string lib("lib");
lib += dir_or_file;
lib += ".so";
gSysten->Load(lib.c_str());
}
else {
Warning("LoadLibraryList",
"Unknown option %s in %s", comp.c_str(), str);
continue;
}
}
}
Perhaps code like this should be added to the command line
handling, so
that one could execute ROOT with a command line like
root -L/path/to/libs -llibrary -lfoo
which could make batch processing easier.
Yours,
--
___ | Christian Holm Christensen
|_| |
------------------------------------------------------------
-
| | Address: Sankt Hansgade 23, 1. th. Phone: (+45)
35 35 96 91
_| DK-2200 Copenhagen N Cell: (+45)
24 61 85 91
_| Denmark Office: (+45)
353 25 447
____| Email: cholm nbi.dk Web:
www.nbi.dk/~cholm
| |
|
|
[1-3]
|
|