RE: load a list of libs

From: Christian Holm Christensen <cholm_at_nbi.dk>
Date: Tue, 11 Mar 2008 09:11:35 +0100


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 %d\n", 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_at_nbi.dk               Web:    www.nbi.dk/~cholm
 | |
Received on Tue Mar 11 2008 - 09:30:34 CET

This archive was generated by hypermail 2.2.0 : Tue Mar 11 2008 - 11:50:01 CET