#include <iostream.h>
#include <exception>
#include <dlfcn.h>

int main(int argc, char **argv) {

  void *handle;

  // Premier test
  try {
	throw exception ();
  }
  catch (...) {
	cout << "test exception BEFORE LIB LOADING .............."<<endl;
  }

  // Chargement de la lib
  handle = dlopen ("./libbar.so", RTLD_NOW|RTLD_GLOBAL);
  if (!handle) {
	cerr<< "ERREUR : "<< dlerror()<<endl;
	exit(1);
  }

  // Lib OK - Second test
  cout << "dlopen succeded .............."<<endl;
  try {
	throw exception ();
  }
  catch (...) {
	cout << "test exception LIB LOADED .............."<<endl;
  }

  dlclose(handle);
  return 0 ;
}



