libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libtool and MingW, MSVC support


From: Roger While
Subject: Re: libtool and MingW, MSVC support
Date: Mon, 12 Jun 2006 13:08:36 +0200

Look at what we have in OpenCOBOL for
dynamic loading of modules :

#ifdef  USE_LIBDL

#include <dlfcn.h>
#define lt_dlopen(x)    dlopen(x, RTLD_LAZY | RTLD_GLOBAL)
#define lt_dlsym(x, y)  dlsym(x, y)
#define lt_dlclose(x)   dlclose(x)
#define lt_dlerror()    dlerror()
#define lt_ptr_t        void *
#define lt_dlhandle     void *

#elif   defined(_WIN32)

#include <windows.h>
/* Prototype */
static char *   lt_dlerror (void);

static HMODULE
lt_dlopen (const char *x)
{
        if (x == NULL) {
                return GetModuleHandle(NULL);
        }
        return LoadLibrary(x);
}
#define lt_dlsym(x, y)  GetProcAddress(x, y)
#define lt_dlclose(x)   FreeLibrary(x)
static char errbuf[64];
static char *
lt_dlerror()
{
sprintf(errbuf, "LoadLibrary/GetProcAddress error %d", (int)GetLastError());
        return errbuf;
}
#define lt_ptr_t        void *
#define lt_dlinit()
#define lt_dlhandle     HMODULE

#else

#define LT_NON_POSIX_NAMESPACE 1
#include <ltdl.h>

#endif

The app is coded to use the lt_dl calls.
Configure sorts out when USE_LIBDL is set
(native loading, eg. Linux, Cygwin), else redefine when Windows, else
use ltdl.

Roger






reply via email to

[Prev in Thread] Current Thread [Next in Thread]