[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Re: libglpk0: excessive install dependencies
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] Re: libglpk0: excessive install dependencies |
Date: |
Thu, 13 Mar 2008 21:38:39 +0300 |
Vijay,
Thank you for your efforts.
I think the dynamic linking of mysql and odbc dll's for a ms windows
version of the package can be easily implemented, because such
version does not need a configure script (I mean the version compiled
with some native w32 compiler like vc6). Thus, it is sufficient to
enclose the corresponding fragment within #ifdef/#endif and add
necessary -D options in the makefile.
Btw, dynamic loading/unloading can be performed in DllMain; see
file glplib03.c; probably it is a most appropraite place for that.
Andrew Makhorin
> It would be nice to have this change (i.e. explicitly loading the
> dynamic library/shared object related to table feature in MathProg)
> work on MS Windows.
> I ported example on page http://linux.die.net/man/3/dlopen to
> windows. We will need to use ifdefs at come places (loading,
> unloading, and getting function address), but actual function
> invocation is OS independent. I have tested program below on Windows
> XP and it works as expected.
> ---------------------------------------------
> #include<stdio.h>
> #include<stdlib.h>
> #define WINDOWS /* Testing purpose only */
> #ifdef WINDOWS
> #include<windows.h>
> #endif
> int main(int argc, char **argv) {
> #ifdef LINUX
> void *handle;
> char *error;
> #else ifdef WINDOWS
> HINSTANCE handle;
> #endif
> /* Note: OS Indepdent code. */
> double (*cosine)(double);
> #ifdef LINUX
> handle = dlopen ("libm.so", RTLD_LAZY);
> if (!handle) {
> fprintf (stderr, "%s\n", dlerror());
> exit(1);
> }
> #else ifdef WINDOWS
> //handle = LoadLibrary(TEXT("libmySQL"));
> //handle = LoadLibrary(TEXT("odbc32"));
> handle = LoadLibrary(TEXT("msvcrt"));
> if(!handle) {
> fprintf(stderr, "Could not load shared library msvcrt.dll.\n");
> exit(1);
> }
> #endif
> #ifdef LINUX
> dlerror(); /* Clear any existing error */
> cosine = dlsym(handle, "cos");
> if ((error = dlerror()) != NULL) {
> fprintf (stderr, "%s\n", error);
> exit(1);
> }
> #else ifdef WINDOWS
> cosine = (void*)GetProcAddress(handle, "cos");
> if(!cosine) {
> fprintf(stderr, "Could not find function #39;cos #39; in dll.\n");
> }
> #endif
> /* Note: OS Indepdent code. */
> printf ("%f\n", (*cosine)(2.0));
>
> #ifdef LINUX
> dlclose(handle);
> #else if WINDOWS
> FreeLibrary(handle);
> #endif
> return 0;
> }
> On Tue, Mar 11, 2008 at 1:48 AM, Andrew Makhorin <address@hidden> wrote:
>> I found a guide for the program changes needed at
>> http://linux.die.net/man/3/dlopen
>> According to
>> http://sourceware.org/autobook/autobook/autobook_167.html
>> Configure.ac also will need changes: At least AC_LIBTOOL_DLOPEN must
>> be included.
>> Do You know of better guides for shared libraries?
> Please see:
> http://www.gnu.org/software/libtool/manual.html
>> I will try to make an implementation until Sunday March 17th.
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-glpk
[Help-glpk] Re: libglpk0: excessive install dependencies, Xypron, 2008/03/16