]> Creatis software - bbtk.git/blob - kernel/src/bbtkDynamicLibraryHandling.h
Recreated the complete cvs tree because the project architecture deeply changed
[bbtk.git] / kernel / src / bbtkDynamicLibraryHandling.h
1 /*=========================================================================
2                                                                                 
3 Program:   bbtk
4 Module:    $RCSfile: bbtkDynamicLibraryHandling.h,v $
5 Language:  C++
6
7 Date:      $Date: 2008/01/22 15:02:00 $
8 Version:   $Revision: 1.1.1.1 $
9                                                                                 
10
11 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
12 l'Image). All rights reserved. See doc/license.txt or
13 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
14
15 This software is distributed WITHOUT ANY WARRANTY; without even
16 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
17 PURPOSE.  See the above copyright notices for more information.
18
19 =========================================================================*/
20 /**
21  *\file
22  *\brief Dynamic library loading stuff (OS dependent)
23  */
24
25 // System dependent includes for loading dynamic libraries
26 #if defined(__GNUC__)
27 // GCC compiler
28
29 // dlopen, dlsym, etc.
30 #include <dlfcn.h>
31
32 // dlopen loading mode : 
33 // instant/delayed symbol resolution
34 #ifndef BBTK_RTLD_NOW
35 #  define BBTK_RTLD_TIME RTLD_LAZY
36 #else
37 #  define BBTK_RTLD_TIME RTLD_NOW
38 #endif
39 // local/global symbol loading
40 // one **MUST** use RTLD_GLOBAL in order to have 
41 // the RTTI mechanism travel correctly across packages (typeid,dynamic_cast...)
42 // however this can cause problems (symbol clashes) ...
43 // see :
44 // http://gcc.gnu.org/faq.html#dso
45 // http://gcc.gnu.org/ml/gcc/2003-04/msg00256.html
46 // http://gcc.gnu.org/ml/gcc-bugs/2003-10/msg02771.html
47 #ifndef BBTK_RTLD_LOCAL
48 #  define BBTK_RTLD_SCOPE RTLD_GLOBAL
49 #else 
50 #  define BBTK_RTLD_SCOPE RTLD_LOCAL
51 #endif
52
53 // dl handler type
54 namespace bbtk 
55 {
56   typedef void* DynamicLibraryHandler;
57 }
58
59 #elif defined(_WIN32)
60 // Win32
61 // HINSTANCE, LoadLibrary, etc. definition
62 #include "Windows.h"
63 // dl handler type
64 namespace bbtk 
65 {
66   typedef HINSTANCE DynamicLibraryHandler;
67 }
68
69 #else
70
71 ERROR !! DYNAMIC LIBRARY LOADING NOT IMPLEMENTED FOR YOUR SYSTEM
72
73 #endif