[Clam-devel] Successfull dynamic loading spike on Linux

Pau Arumi parumi at iua.upf.edu
Fri Jun 29 10:47:09 PDT 2007


En/na David García Garzón ha escrit:
> We have CLAM plugins!!!

So doing a simple dlopen the factory creators get registered to
the singleton factory... absolutely great!

This is more pressure to Andreas to finish the enriched
factory... ;)

To give context to others: we are pushing for this milestone:
* use clam libs as if they were ladspa plugins, automatically
   available in NE processing tree.

pau



> Following Pau comments and doing a fast copy of LadspaLoader code, I did a 
> fast spike on loading DLL's of processing such the ones on wednesday 
> howto[1], but now in runtime looking at the content of a directory. Not that 
> difficult, it was just a matter of trying.
> 
> [1] http://clam.iua.upf.edu/wikis/clam/index.php/Building_a_processing_library
> 
> If you want to try it:
> * Add the attached cxx to the NetworkEditor 'src' (should be clam_core)
> * Change the hardcoded path to the place where you'll put the processing dlls
> * Compile NetEditor
> * Build a processing dll with some new processings following the howto[1]
> * Move the processing dll to the path
> * Run NetworkEditor
> 
> Enjoy. :-)
> 
> TODO's:
> * Clean up the code
> * Take the path from somewhere else (Environment? installpath? Colon 
> separated?)
> * Multiplatform directory navigation
> * Multiplatform library loading
> * Add metadata symbols
> * Check metadata symbols to identify CLAM libraries before loading
> * Be verbose on errors (dlerr)
> 
> David.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> #include <dlfcn.h>
> #include <dirent.h>
> #include <iostream>
> #include <string>
> 
> class DynamicProcessinLibraryLoader
> {
> public:
> 	DynamicProcessinLibraryLoader(const std::string & directory="libs")
> 	{
> 		DIR* dir = opendir(directory.c_str());
> 		if (!dir)
> 		{
> 			std::cout << "[Plugins] warning: could not open CLAM plugins dir: " << directory << std::endl;
> 			return;
> 		}
> 		struct dirent * dirEntry;
> 		while ( (dirEntry = readdir(dir)) )
> 		{
> 			std::string pluginFilename(dirEntry->d_name);
> 			if(pluginFilename == "." || pluginFilename == "..")
> 				continue;
> 			std::string pluginFullFilename(directory + std::string("/") + pluginFilename);
> 			std::cout << "[Plugins] Loading CLAM plugin: " << pluginFullFilename << std::endl;
> 			void* handle = dlopen( pluginFullFilename.c_str(), RTLD_NOW);
> 			if (handle) continue; // Ok
> 			std::cout << "[Plugins] warning: failed to load CLAM plugin: " << pluginFullFilename << std::endl;
> 			
> 		}
> 	}
> };
> 
> static DynamicProcessinLibraryLoader dllLoader("LibSpike");
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Clam-devel mailing list
> Clam-devel at llistes.projectes.lafarga.org
> https://llistes.projectes.lafarga.org/cgi-bin/mailman/listinfo/clam-devel





More information about the clam-devel mailing list