#include <iostream>
#include <dlfcn.h>
#include "MdcData/MdcHit.h"
Go to the source code of this file.
Functions | |
int | main () |
int main | ( | ) |
Definition at line 6 of file test.cxx.
00006 { 00007 using std::cout; 00008 using std::cerr; 00009 00010 cout << "C++ dlopen demo\n\n"; 00011 00012 // open the library 00013 cout << "Opening MdcData.so...\n"; 00014 void* handle = dlopen("../rh73_gcc32/libMdcData.so", RTLD_LAZY); 00015 00016 if (!handle) { 00017 cerr << "Cannot open library: " << dlerror() << '\n'; 00018 return 1; 00019 } 00020 00021 MdcHit hit(NULL,NULL); 00022 00023 /* // load the symbol 00024 cout << "Loading symbol hello...\n"; 00025 typedef void (*hello_t)(); 00026 hello_t hello = (hello_t) dlsym(handle, "hello"); 00027 if (!hello) { 00028 cerr << "Cannot load symbol 'hello': " << dlerror() << 00029 '\n'; 00030 dlclose(handle); 00031 return 1; 00032 } 00033 00034 // use it to do the calculation 00035 cout << "Calling hello...\n"; 00036 hello(); 00037 */ 00038 // close the library 00039 cout << "Closing library...\n"; 00040 dlclose(handle); 00041 }