-
-#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.
- if (verbose) {
- std::cout <<"[" <<libname<<"] can't be open" << std::endl;
- std::cout << " " <<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.
- if (verbose)
- std::cout <<" -->[" <<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("GetPackage : could not load package \""<<pkgname
- <<"\" [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("DeletePackage : could not load package \""<<pkgname
- <<"\" [symbol "<<delfname<<"] :"<<dlerror());
- }
-
-#elif defined(_WIN32)
-
- HINSTANCE handler;
-
- SetErrorMode(0);
- handler = LoadLibrary(libname.c_str());
- if (!handler){
- if (verbose)
- // The following is *NOT* a debug time message :
- // It's a user intended message.
- // Please don't remove it.
- std::cout <<" no handler for [" <<libname<<"];" << std::endl;
- return false;// Problem with the found library
- }
- if (verbose)
- std::cout <<" --->[" <<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)
- {
- FreeLibrary(handler);
- bbtkError("[2]could not load package \""<<pkgname
- <<"\" : "<<delfname<<" symbol not found (is it a bbtk package lib ?)");
- // look how to get the error message on win
- //<<dlerror());
- }
-#else
- bbtkError("neither __GNUC__ nor _WIN32 ?!? How did you compile ?");
-#endif
-
- // Stores the package
- PackageInfoType pack;
- pack.mDynamicLibraryHandler = handler;
- // Invokes the accessor to the PackageUnit pointer
- pack.mPackage = ((PackageAccessor)getpack)();
-
- mPackageMap[pkgname] = pack;
-
- // Test bbtk build version ok
- if ( pack.mPackage->GetBBTKVersion() != bbtk::GetVersion() )
- {
- std::string v(pack.mPackage->GetBBTKVersion());
- UnLoadPackage(pkgname);
- bbtkError(" package build with bbtk version "
- << v
- << " whereas application build with version "
- << bbtk::GetVersion());
- }
-
- std::string separator =
- ConfigurationFile::GetInstance().Get_file_separator ();
- //BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH)
- std::string docreldoc = separator + "packages" + separator + pkgname
- + separator + "bbdoc" + separator + "index.html";
- std::string reldoc = ".." + separator + ".." + separator
- + ".." + docreldoc;
- std::string doc = path + separator + ".." + separator
- + BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH)
- + docreldoc;
-
- pack.mPackage->SetDocURL(doc);
- pack.mPackage->SetDocRelativeURL(reldoc);
-
- //===================================================================
- bbtkMessage("Output",2,pack.mPackage->GetName()<<" "
- <<pack.mPackage->GetVersion()
- <<" (bbtk "
- <<pack.mPackage->GetBBTKVersion()<<") "
- <<pack.mPackage->GetAuthor() << " Keyword(s) :"
- <<pack.mPackage->GetKeyword()
- <<std::endl);
- bbtkMessage("Output",2,pack.mPackage->GetDescription()<<std::endl);
- //===================================================================
-
- bbtkDebugDecTab("Core",7);
- return true;