Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 21, 2006, 10:48:52 PM (18 years ago)
Author:
bensch
Message:

orxonox/dylib: now the dylibLoader should work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/shared_lib/src/util/loading/dynamic_loader.cc

    r7171 r7174  
    1717
    1818#include "dynamic_loader.h"
    19 
     19#include "resource_manager.h"
    2020
    2121using namespace std;
    22 
    2322
    2423/**
     
    3635}
    3736
     37/**
     38 * @brief initializes the Dynamic Library loader
     39 * @returns true on succes, false otherwise
     40 */
     41bool DynamicLoader::initialize()
     42{
     43  if (lt_dlinit () != 0)
     44  {
     45    PRINTF(1)("Initializing LT_DL_LIB: %s\n", lt_dlerror());
     46    return false;
     47  }
     48  else
     49    return true;
     50}
    3851
    3952/**
     
    5063bool DynamicLoader::loadDynamicLib(const std::string& libName)
    5164{
    52   if (lt_dlinit () != 0)
    53   {
    54     PRINTF(1)("Initializing LT_DL_LIB\n");
    55   }
    56   this->handle = lt_dlopen(&libName[0]);
     65  DynamicLoader::initialize();
     66
     67  this->handle = lt_dlopenext(&libName[0]);
    5768  if(this->handle == NULL)
    5869  {
    5970    return false;
    6071  }
    61   //void *mkr = dlsym( this->handle, "maker");
    6272}
    6373
    6474bool DynamicLoader::loadDyLib(const char* libName)
    6575{
    66   if (lt_dlinit () != 0)
    67   {
    68     PRINTF(1)("Initializing LT_DL_LIB\n");
    69   }
    70 
     76  DynamicLoader::initialize();
    7177  void* handle;
    72   handle = lt_dlopen(libName);
     78  handle = lt_dlopenext(libName);
    7379  if(handle == NULL)
    7480  {
     
    7783    return false;
    7884  }
    79 //  void *mkr = dlsym("maker");
    8085
    8186}
    8287
     88void DynamicLoader::addSearchDir(const char* searchDir)
     89{
     90  DynamicLoader::initialize();
    8391
    84 BaseObject* DynamicLoader::fabricateObject(const TiXmlElement* root) const
     92  lt_dladdsearchdir(searchDir);
     93}
     94
     95/**
     96 * @param relSearchDir: the Relative directory to add to searchPath of lt_dl
     97 * @returns true if the Path was Valid, false otherwise
     98 */
     99bool DynamicLoader::addSearchDirRelative(const char* relSearchDir)
    85100{
     101  char* absSearchDir = ResourceManager::getAbsDir(relSearchDir);
     102  if (ResourceManager::isDir(absSearchDir))
     103  {
     104    DynamicLoader::addSearchDir(absSearchDir);
     105    delete[] absSearchDir;
     106    return true;
     107  }
     108  else
     109  {
     110    delete[] absSearchDir;
     111    return false;
     112  }
    86113}
     114
     115
     116const char* DynamicLoader::getSearchDir()
     117{
     118  return lt_dlgetsearchpath();
     119}
Note: See TracChangeset for help on using the changeset viewer.