Changeset: c1a6d07b399e for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c1a6d07b399e Modified Files: MonetDB/src/gdk/gdk_posix.mx MonetDB5/src/mal/mal_linker.mx MonetDB5/src/tools/Makefile.ag Branch: default Log Message:
Fix getting symbols from DLL on Windows. We use dlsym() to look up symbols in dynamically loaded modules and in the main program. When a symbol is located in a DLL which is linked to the main program (i.e. not dynamically loaded using dlopen), we need to specify the name of that library in the call to GetModuleHandle, otherwise we won't find the symbols. diffs (69 lines): diff -r c4d50d00c802 -r c1a6d07b399e MonetDB/src/gdk/gdk_posix.mx --- a/MonetDB/src/gdk/gdk_posix.mx Tue Dec 07 17:18:16 2010 +0100 +++ b/MonetDB/src/gdk/gdk_posix.mx Tue Dec 07 17:28:16 2010 +0100 @@ -258,6 +258,8 @@ to an equivalent win_*() function (which in its implementation calls through to the WIN32 function). @{ @h +gdk_export void *mdlopen(const char *library, int mode); + #ifdef NATIVE_WIN32 #define RTLD_LAZY 1 @@ -1303,6 +1305,13 @@ return (*pathname == DIR_SEP); } +void * +mdlopen(const char *library, int mode) +{ + (void) library; + return dlopen(NULL, mode); +} + #ifdef WIN32 #include <windows.h> #endif @@ -1830,6 +1839,13 @@ #endif void * +mdlopen(const char *library, int mode) +{ + (void) mode; + return GetModuleHandle(library); +} + +void * dlopen(const char *file, int mode) { (void) mode; diff -r c4d50d00c802 -r c1a6d07b399e MonetDB5/src/mal/mal_linker.mx --- a/MonetDB5/src/mal/mal_linker.mx Tue Dec 07 17:18:16 2010 +0100 +++ b/MonetDB5/src/mal/mal_linker.mx Tue Dec 07 17:28:16 2010 +0100 @@ -159,8 +159,11 @@ Try the program libraries at large or run through all loaded files and try to resolve the functionname again. @c - if (dl == NULL) - dl = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL); + if (dl == NULL) { + /* the first argument must be the same as the base name of the + * library that is created in src/tools */ + dl = mdlopen("libmonetdb5", RTLD_NOW | RTLD_GLOBAL); + } if( dl != NULL){ adr = (MALfcn) dlsym(dl, fcnname); if( adr != NULL) diff -r c4d50d00c802 -r c1a6d07b399e MonetDB5/src/tools/Makefile.ag --- a/MonetDB5/src/tools/Makefile.ag Tue Dec 07 17:18:16 2010 +0100 +++ b/MonetDB5/src/tools/Makefile.ag Tue Dec 07 17:28:16 2010 +0100 @@ -20,6 +20,8 @@ $(monetdbmapi_CFLAGS) $(monetdbcommon_CFLAGS) $(monetdbstream_CFLAGS) \ $(openssl_CFLAGS) $(pcre_CFLAGS) $(libxml2_CFLAGS) +# the name (libmonetdb5) is also used in ../mal/mal_linker.mx +# if you change the name here, change it there as well lib_monetdb5 = { NAME = monetdb5 SCRIPTS = mal _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list