-#if defined(__GNUC__)
-
- void *handler;
- handler = dlopen(libname.c_str(),
- BBTK_RTLD_TIME | BBTK_RTLD_SCOPE );
- if (!handler)
- {
- // The following is *NOT* a debug time message :
- // It's a user intended message.
- // Please don't remove it.
- bbtkError("Could not open shared library [" <<libname<<"] : "
- <<dlerror() << std::endl);
-
- return false; // try next path
- }
-
- // The following is *NOT* a debug time message :
- // It's a user intended message.
- // Please don't remove it.
- bbtkMessage("Output",2," -->[" <<libname<<"] found" << std::endl);
-
- // Loads the Package accessor
-
- std::string getpackname(pkgname);
- getpackname += "GetPackage";
- void *getpack = dlsym(handler, getpackname.c_str());
- if (!getpack)
- {
- dlclose(handler);
- bbtkError("Shared library ["<<libname<<"] is not a valid bbtk package."
- <<" Symbol ["<<getpackname<<"] :"<<dlerror());
- }
-
- // Verifies that the Package delete function is present
- std::string delfname(pkgname);
- delfname += "DeletePackage";
- void *delf = dlsym(handler, delfname.c_str());
- if (!delf)
- {
- dlclose(handler);
- bbtkError("Shared library ["<<libname<<"] is not a valid bbtk package."
- <<" Symbol ["<<delfname<<"] :"<<dlerror());
- }
-
-#elif defined(_WIN32)
-
- HINSTANCE handler;
-
- SetErrorMode(0);
- handler = LoadLibrary(libname.c_str());
- if (!handler)
- {
- // The following is *NOT* a debug time message :
- // It's a user intended message.
- // Please don't remove it.
- bbtkError("Error loading library [" <<libname<<"]" << std::endl);
- return false;// Problem with the found library
- }
-
- bbtkMessage("Output",2," --->[" <<libname<<"] found" << std::endl);
-
- // Loads the Package accessor
-
- std::string getpackname(pkgname);
- getpackname += "GetPackage";
- void *getpack = GetProcAddress(handler, getpackname.c_str());
- if (!getpack)
- {
- FreeLibrary(handler);
- bbtkError("[1] Could not load package \""<<pkgname
- <<"\" : "<<getpackname<<" symbol not found (is it a bbtk package lib ?)");
- // look how to get the error message on win
- //<<dlerror());
- }
- // Verifies that the Package delete function is present
- std::string delfname(pkgname);
- delfname += "DeletePackage";
- void *delf = GetProcAddress(handler, delfname.c_str());
- if (!delf)