loadlibs.C
Go to the documentation of this file.
1 Long_t load_single_lib(const char * libname)
2 {
3  return gSystem->Load(libname);
4 }
5 
6 Long_t load_libs_from_command(const char * list_libs_command, bool verbose = false)
7 { // Takes a linker-style list of libs (eg "-lmygreatlib -lmylessgoodlib" )
8  // and loads each using gSystem::Load()
9  // Returns 0 on success, 1 on failure
10  Long_t status = 0;
11  FILE * f = gSystem->OpenPipe(list_libs_command,"r");
12 
13  TPRegexp re("-l([\\d\\w]*)");
14  while (true) {
15  TString line;
16  if (!line.Gets(f)) {break;}
17  TObjArray * tokens = line.Tokenize(" ");
18  for (int i = 0 ; i < tokens->GetEntries() ; i++) {
19  TObjString * token_os = static_cast<TObjString*>(tokens->At(i));
20  if (!token_os) {continue;}
21  TObjArray * matches = re.MatchS(token_os->GetString());
22  if (matches->GetEntries()!=2) { continue; }
23  TObjString * libname_os = static_cast<TObjString*>(matches->At(1));
24  if (!libname_os) {continue;}
25  TString full_libname = "lib"+libname_os->GetString();
26  Long_t this_status = load_single_lib(full_libname.Data());
27  if (verbose) std::cout<<full_libname<<":\t"<<this_status<<std::endl;
28  status = (status || this_status);
29  delete matches;
30  }
31  delete tokens;
32  }
33  gSystem->ClosePipe(f);
34  return status;
35 }
36 
37 int loadlibs()
38 {
39  TString libs0 = gSystem->GetDynamicPath();
40  TString libs = libs0 + ":/usr/local/lib64:/usr/lib64:/lib64:"+
41  "/usr/local/lib/:/usr/lib/:/lib:/opt/lib:/opt/local/lib";
42  gSystem->SetDynamicPath(libs.Data());
43 
44  // PYTHIA 6 lib
45  gSystem->Load("libPythia6");
46 
47  // extra ROOT libs
48  gSystem->Load("libPhysics");
49  gSystem->Load("libEG");
50  gSystem->Load("libEGPythia6");
51  gSystem->Load("libGeom");
52  gSystem->Load("libTree");
53 
54  // libxml2 and log4cpp libs
55  gSystem->Load("libxml2");
56  gSystem->Load("liblog4cpp");
57 
58  // GSL
59  gSystem->Load("libgslcblas");
60  gSystem->Load("libgsl");
61  //~ load_libs_from_command("gsl-config --libs"); // not guaranteed to be in the right order
62 
63  //
64  // GENIE libs
65  //
66 
67  Long_t status = load_libs_from_command("genie-config --libs");
68 
69  if (status) {
70  std::cout<<"Failed to load GENIE libraries"<<std::endl;
71  exit(1);
72  }
73  return 0;
74 }
75 
int status
Definition: fabricate.py:1613
Long_t load_libs_from_command(const char *list_libs_command, bool verbose=false)
Definition: loadlibs.C:6
Long_t load_single_lib(const char *libname)
Definition: loadlibs.C:1
void loadlibs()
Definition: loadlibs.C:9
Definition: __init__.py:1
OStream cout
Definition: OStream.cxx:6
exit(0)