summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvestre Ledru <sylvestre.ledru@scilab.org>2008-07-18 15:38:40 +0000
committerSylvestre Ledru <sylvestre.ledru@scilab.org>2008-07-18 15:38:40 +0000
commit3255d7f315b0dd4cab79abab67394bd8455edd35 (patch)
tree9eaaa9eeae902585ce1d0895d88ca2c98fc60301
parent8ef3dafefa5aae7ab7a7e772c1cff34413342d6a (diff)
downloadscilab-3255d7f315b0dd4cab79abab67394bd8455edd35.zip
scilab-3255d7f315b0dd4cab79abab67394bd8455edd35.tar.gz
* No longer explicitly link against lib which should be only loaded at
runtime * profile of callDynamicGateway updated to have also the name of the module * if dlopen fails (like it is the case under Suse - see bug #2875), try to link manually (ie full path) the lib instead of browsing all the directory
-rw-r--r--scilab/modules/Makefile.am23
-rw-r--r--scilab/modules/Makefile.in20
-rw-r--r--scilab/modules/core/src/c/callDynamicGateway.c43
-rw-r--r--scilab/modules/core/src/c/callDynamicGateway.h10
-rw-r--r--scilab/modules/core/src/c/gw_dynamic_generic.c2
5 files changed, 67 insertions, 31 deletions
diff --git a/scilab/modules/Makefile.am b/scilab/modules/Makefile.am
index 38170fa..7159f8f 100644
--- a/scilab/modules/Makefile.am
+++ b/scilab/modules/Makefile.am
@@ -113,7 +113,6 @@ endif
113 113
114ALL_LIBS= $(top_builddir)/modules/fileio/libscifileio.la \ 114ALL_LIBS= $(top_builddir)/modules/fileio/libscifileio.la \
115$(top_builddir)/modules/mexlib/libmex.la \ 115$(top_builddir)/modules/mexlib/libmex.la \
116 $(top_builddir)/modules/arnoldi/libsciarnoldi.la \
117 $(top_builddir)/modules/boolean/libsciboolean.la \ 116 $(top_builddir)/modules/boolean/libsciboolean.la \
118 $(top_builddir)/modules/cacsd/libscicacsd.la \ 117 $(top_builddir)/modules/cacsd/libscicacsd.la \
119 $(top_builddir)/modules/core/libscicore.la \ 118 $(top_builddir)/modules/core/libscicore.la \
@@ -132,14 +131,9 @@ $(top_builddir)/modules/mexlib/libmex.la \
132 $(top_builddir)/modules/io/libsciio.la \ 131 $(top_builddir)/modules/io/libsciio.la \
133 $(top_builddir)/modules/linear_algebra/libscilinear_algebra.la \ 132 $(top_builddir)/modules/linear_algebra/libscilinear_algebra.la \
134 $(top_builddir)/modules/localization/libscilocalization.la \ 133 $(top_builddir)/modules/localization/libscilocalization.la \
135 $(top_builddir)/modules/metanet/libscimetanet.la \
136 $(top_builddir)/modules/optimization/libscioptimization.la \
137 $(top_builddir)/modules/polynomials/libscipolynomials.la \ 134 $(top_builddir)/modules/polynomials/libscipolynomials.la \
138 $(top_builddir)/modules/randlib/libscirandlib.la \
139 $(top_builddir)/modules/symbolic/libscisymbolic.la \
140 $(top_builddir)/modules/signal_processing/libscisignal_processing.la \ 135 $(top_builddir)/modules/signal_processing/libscisignal_processing.la \
141 $(top_builddir)/modules/special_functions/libscispecial_functions.la \ 136 $(top_builddir)/modules/special_functions/libscispecial_functions.la \
142 $(top_builddir)/modules/sound/libscisound.la \
143 $(top_builddir)/modules/statistics/libscistatistics.la \ 137 $(top_builddir)/modules/statistics/libscistatistics.la \
144 $(top_builddir)/modules/time/libscitime.la \ 138 $(top_builddir)/modules/time/libscitime.la \
145 $(top_builddir)/modules/windows_tools/libsciwindows_tools.la \ 139 $(top_builddir)/modules/windows_tools/libsciwindows_tools.la \
@@ -150,16 +144,23 @@ $(top_builddir)/modules/mexlib/libmex.la \
150 $(top_builddir)/modules/console/libsciconsole.la \ 144 $(top_builddir)/modules/console/libsciconsole.la \
151 $(top_builddir)/modules/completion/libscicompletion.la \ 145 $(top_builddir)/modules/completion/libscicompletion.la \
152 $(top_builddir)/modules/history_manager/libscihistory_manager.la \ 146 $(top_builddir)/modules/history_manager/libscihistory_manager.la \
153 $(top_builddir)/modules/spreadsheet/libscispreadsheet.la \
154 $(top_builddir)/modules/action_binding/libsciaction_binding.la \ 147 $(top_builddir)/modules/action_binding/libsciaction_binding.la \
155 $(top_builddir)/modules/dynamic_link/libscidynamic_link.la \ 148 $(top_builddir)/modules/dynamic_link/libscidynamic_link.la \
156 $(top_builddir)/modules/output_stream/libscioutput_stream.la \ 149 $(top_builddir)/modules/output_stream/libscioutput_stream.la \
157 $(top_builddir)/modules/matio/libscimatio.la 150 $(top_builddir)/modules/sound/libscisound.la
158 151
159# \ 152# These libs are loaded dynamical by Scilab
153# $(top_builddir)/modules/matio/libscimatio.la
154# $(top_builddir)/modules/randlib/libscirandlib.la
155# $(top_builddir)/modules/optimization/libscioptimization.la
156# $(top_builddir)/modules/arnoldi/libsciarnoldi.la
157# $(top_builddir)/modules/symbolic/libscisymbolic.la
158# $(top_builddir)/modules/metanet/libscimetanet.la
159# $(top_builddir)/modules/spreadsheet/libscispreadsheet.la
160
161# Dev in progress
160# $(top_builddir)/modules/helptools/libscihelptools.la 162# $(top_builddir)/modules/helptools/libscihelptools.la
161 163
162
163# Core modules 164# Core modules
164libscilab_la_LIBADD = $(ALL_LIBS) 165libscilab_la_LIBADD = $(ALL_LIBS)
165 166
diff --git a/scilab/modules/Makefile.in b/scilab/modules/Makefile.in
index 0dfd7b4..7d84a92 100644
--- a/scilab/modules/Makefile.in
+++ b/scilab/modules/Makefile.in
@@ -352,7 +352,6 @@ libscilab_la_SOURCES =
352libscilab_la_LDFLAGS = $(am__append_3) $(am__append_4) 352libscilab_la_LDFLAGS = $(am__append_3) $(am__append_4)
353ALL_LIBS = $(top_builddir)/modules/fileio/libscifileio.la \ 353ALL_LIBS = $(top_builddir)/modules/fileio/libscifileio.la \
354$(top_builddir)/modules/mexlib/libmex.la \ 354$(top_builddir)/modules/mexlib/libmex.la \
355 $(top_builddir)/modules/arnoldi/libsciarnoldi.la \
356 $(top_builddir)/modules/boolean/libsciboolean.la \ 355 $(top_builddir)/modules/boolean/libsciboolean.la \
357 $(top_builddir)/modules/cacsd/libscicacsd.la \ 356 $(top_builddir)/modules/cacsd/libscicacsd.la \
358 $(top_builddir)/modules/core/libscicore.la \ 357 $(top_builddir)/modules/core/libscicore.la \
@@ -371,14 +370,9 @@ $(top_builddir)/modules/mexlib/libmex.la \
371 $(top_builddir)/modules/io/libsciio.la \ 370 $(top_builddir)/modules/io/libsciio.la \
372 $(top_builddir)/modules/linear_algebra/libscilinear_algebra.la \ 371 $(top_builddir)/modules/linear_algebra/libscilinear_algebra.la \
373 $(top_builddir)/modules/localization/libscilocalization.la \ 372 $(top_builddir)/modules/localization/libscilocalization.la \
374 $(top_builddir)/modules/metanet/libscimetanet.la \
375 $(top_builddir)/modules/optimization/libscioptimization.la \
376 $(top_builddir)/modules/polynomials/libscipolynomials.la \ 373 $(top_builddir)/modules/polynomials/libscipolynomials.la \
377 $(top_builddir)/modules/randlib/libscirandlib.la \
378 $(top_builddir)/modules/symbolic/libscisymbolic.la \
379 $(top_builddir)/modules/signal_processing/libscisignal_processing.la \ 374 $(top_builddir)/modules/signal_processing/libscisignal_processing.la \
380 $(top_builddir)/modules/special_functions/libscispecial_functions.la \ 375 $(top_builddir)/modules/special_functions/libscispecial_functions.la \
381 $(top_builddir)/modules/sound/libscisound.la \
382 $(top_builddir)/modules/statistics/libscistatistics.la \ 376 $(top_builddir)/modules/statistics/libscistatistics.la \
383 $(top_builddir)/modules/time/libscitime.la \ 377 $(top_builddir)/modules/time/libscitime.la \
384 $(top_builddir)/modules/windows_tools/libsciwindows_tools.la \ 378 $(top_builddir)/modules/windows_tools/libsciwindows_tools.la \
@@ -389,14 +383,22 @@ $(top_builddir)/modules/mexlib/libmex.la \
389 $(top_builddir)/modules/console/libsciconsole.la \ 383 $(top_builddir)/modules/console/libsciconsole.la \
390 $(top_builddir)/modules/completion/libscicompletion.la \ 384 $(top_builddir)/modules/completion/libscicompletion.la \
391 $(top_builddir)/modules/history_manager/libscihistory_manager.la \ 385 $(top_builddir)/modules/history_manager/libscihistory_manager.la \
392 $(top_builddir)/modules/spreadsheet/libscispreadsheet.la \
393 $(top_builddir)/modules/action_binding/libsciaction_binding.la \ 386 $(top_builddir)/modules/action_binding/libsciaction_binding.la \
394 $(top_builddir)/modules/dynamic_link/libscidynamic_link.la \ 387 $(top_builddir)/modules/dynamic_link/libscidynamic_link.la \
395 $(top_builddir)/modules/output_stream/libscioutput_stream.la \ 388 $(top_builddir)/modules/output_stream/libscioutput_stream.la \
396 $(top_builddir)/modules/matio/libscimatio.la 389 $(top_builddir)/modules/sound/libscisound.la
397 390
398 391
399# \ 392# These libs are loaded dynamical by Scilab
393# $(top_builddir)/modules/matio/libscimatio.la
394# $(top_builddir)/modules/randlib/libscirandlib.la
395# $(top_builddir)/modules/optimization/libscioptimization.la
396# $(top_builddir)/modules/arnoldi/libsciarnoldi.la
397# $(top_builddir)/modules/symbolic/libscisymbolic.la
398# $(top_builddir)/modules/metanet/libscimetanet.la
399# $(top_builddir)/modules/spreadsheet/libscispreadsheet.la
400
401# Dev in progress
400# $(top_builddir)/modules/helptools/libscihelptools.la 402# $(top_builddir)/modules/helptools/libscihelptools.la
401 403
402# Core modules 404# Core modules
diff --git a/scilab/modules/core/src/c/callDynamicGateway.c b/scilab/modules/core/src/c/callDynamicGateway.c
index 51392b3..70506e7 100644
--- a/scilab/modules/core/src/c/callDynamicGateway.c
+++ b/scilab/modules/core/src/c/callDynamicGateway.c
@@ -12,21 +12,52 @@
12 */ 12 */
13#include <stdio.h> 13#include <stdio.h>
14#include <string.h> 14#include <string.h>
15#include <stdlib.h>
15#include "machine.h" 16#include "machine.h"
16#include "callDynamicGateway.h" 17#include "callDynamicGateway.h"
17#include "MALLOC.h" 18#include "MALLOC.h"
18#include "Scierror.h" 19#include "Scierror.h"
19#include "localization.h" 20#include "localization.h"
21#include "setgetSCIpath.h"
20/*--------------------------------------------------------------------------*/ 22/*--------------------------------------------------------------------------*/
21dynamic_gateway_error_code callDynamicGateway(char *dynLibName, 23dynamic_gateway_error_code callDynamicGateway(char *moduleName,
22 char *gw_name, 24 char *dynLibName,
23 DynLibHandle *hlib, 25 char *gw_name,
24 PROC_GATEWAY *ptrGateway) 26 DynLibHandle *hlib,
27 PROC_GATEWAY *ptrGateway)
25{ 28{
26 if (*hlib == NULL) 29 if (*hlib == NULL)
27 { 30 {
28 *hlib = LoadDynLibrary(dynLibName); 31 /* Under Linux/Unix, load thanks to dlopen */
29 if (*hlib == NULL) return DYN_GW_LOAD_LIBRARY_ERROR; 32 *hlib = LoadDynLibrary(dynLibName);
33#ifdef _MSC_VER
34 if (*hlib == NULL) {
35 return DYN_GW_LOAD_LIBRARY_ERROR;
36 }
37#else
38 if (*hlib == NULL) {
39 /* Haven't been able to find the lib with dlopen...
40 * This can happen for two reasons:
41 * - the lib must be dynamically linked
42 * - Some silly issues under Suse (see bug #2875)
43 * Note that we are handling only the "source tree build"
44 * because libraries are split (they are in the same directory
45 * in the binary)
46 */
47 char *SciPath = getSCIpath();
48 #define PATHTOMODULE "/modules/"
49 #define LT_OBJDIR "/.libs/"
50
51 /* Build the full path to the library */
52 char *pathToLib=(char*) MALLOC((strlen(SciPath)+strlen(PATHTOMODULE)+strlen(moduleName)+strlen(LT_OBJDIR)+strlen(dynLibName)+1)*sizeof(char));
53 sprintf(pathToLib,"%s%s%s%s%s",SciPath,PATHTOMODULE,moduleName,LT_OBJDIR,dynLibName);
54
55 *hlib = LoadDynLibrary(pathToLib);
56 if (*hlib == NULL) {
57 return DYN_GW_LOAD_LIBRARY_ERROR;
58 }
59#endif
60 }
30 } 61 }
31 62
32 if (*ptrGateway == NULL) 63 if (*ptrGateway == NULL)
diff --git a/scilab/modules/core/src/c/callDynamicGateway.h b/scilab/modules/core/src/c/callDynamicGateway.h
index c2ae170..a566b1b 100644
--- a/scilab/modules/core/src/c/callDynamicGateway.h
+++ b/scilab/modules/core/src/c/callDynamicGateway.h
@@ -26,16 +26,18 @@ typedef enum { DYN_GW_NO_ERROR = 0,
26 26
27/** 27/**
28* load and call a scilab gateway 28* load and call a scilab gateway
29* @param[in] name of the Scilab module
29* @param[in] name of dynamic library 30* @param[in] name of dynamic library
30* @param[in] gateway name 31* @param[in] gateway name
31* @param[in, out] handle on dynamic library 32* @param[in, out] handle on dynamic library
32* @param[in, out] pointer on gateway function 33* @param[in, out] pointer on gateway function
33* @return error code (DYN_GW_NO_ERROR if it is ok) 34* @return error code (DYN_GW_NO_ERROR if it is ok)
34*/ 35*/
35dynamic_gateway_error_code callDynamicGateway(char *dynLibName, 36dynamic_gateway_error_code callDynamicGateway(char *moduleName,
36 char *gw_name, 37 char *dynLibName,
37 DynLibHandle *hlib, 38 char *gw_name,
38 PROC_GATEWAY *ptrGateway); 39 DynLibHandle *hlib,
40 PROC_GATEWAY *ptrGateway);
39 41
40/** 42/**
41* Build name of dynamic library based on module name 43* Build name of dynamic library based on module name
diff --git a/scilab/modules/core/src/c/gw_dynamic_generic.c b/scilab/modules/core/src/c/gw_dynamic_generic.c
index eff756d..5d193d3 100644
--- a/scilab/modules/core/src/c/gw_dynamic_generic.c
+++ b/scilab/modules/core/src/c/gw_dynamic_generic.c
@@ -31,7 +31,7 @@ int gw_dynamic_generic(char *moduleName,
31 *gatewayName = buildGatewayName(moduleName); 31 *gatewayName = buildGatewayName(moduleName);
32 } 32 }
33 33
34 err = callDynamicGateway(*dynlibName, 34 err = callDynamicGateway(moduleName,*dynlibName,
35 *gatewayName, 35 *gatewayName,
36 hModuleLib, 36 hModuleLib,
37 ptrGatewayFunction); 37 ptrGatewayFunction);