1 /* glpenv08.c (shared library support) */
3 /***********************************************************************
4 * This code is part of GLPK (GNU Linear Programming Kit).
6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
7 * 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
9 * E-mail: <mao@gnu.org>.
11 * GLPK is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * GLPK is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 * License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
23 ***********************************************************************/
31 /* GNU version ********************************************************/
33 #if defined(HAVE_LTDL)
37 void *xdlopen(const char *module)
40 { lib_err_msg(lt_dlerror());
43 h = lt_dlopen(module);
45 { lib_err_msg(lt_dlerror());
47 xerror("xdlopen: %s\n", lt_dlerror());
52 void *xdlsym(void *h, const char *symbol)
55 ptr = lt_dlsym(h, symbol);
57 xerror("xdlsym: %s: %s\n", symbol, lt_dlerror());
61 void xdlclose(void *h)
63 if (lt_dlclose(h) != 0)
64 xerror("xdlclose: %s\n", lt_dlerror());
66 xerror("xdlclose: %s\n", lt_dlerror());
70 /* POSIX version ******************************************************/
72 #elif defined(HAVE_DLFCN)
76 void *xdlopen(const char *module)
78 h = dlopen(module, RTLD_NOW);
80 lib_err_msg(dlerror());
84 void *xdlsym(void *h, const char *symbol)
87 ptr = dlsym(h, symbol);
89 xerror("xdlsym: %s: %s\n", symbol, dlerror());
93 void xdlclose(void *h)
96 xerror("xdlclose: %s\n", dlerror());
100 /* Windows version ****************************************************/
102 #elif defined(__WOE__)
106 void *xdlopen(const char *module)
108 h = LoadLibrary(module);
111 sprintf(msg, "Error %d", GetLastError());
117 void *xdlsym(void *h, const char *symbol)
120 ptr = GetProcAddress(h, symbol);
122 xerror("xdlsym: %s: Error %d\n", symbol, GetLastError());
126 void xdlclose(void *h)
127 { xassert(h != NULL);
129 xerror("xdlclose: Error %d\n", GetLastError());
133 /* NULL version *******************************************************/
137 void *xdlopen(const char *module)
138 { xassert(module == module);
139 lib_err_msg("Shared libraries not supported");
143 void *xdlsym(void *h, const char *symbol)
145 xassert(symbol != symbol);
149 void xdlclose(void *h)