fix library search.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1888 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
244d4128cf
commit
dc9ab3b1c7
46
C/load_dl.c
46
C/load_dl.c
@ -44,9 +44,32 @@ LoadForeign(StringList ofiles, StringList libs,
|
|||||||
char *proc_name, YapInitProc *init_proc)
|
char *proc_name, YapInitProc *init_proc)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
while (libs) {
|
||||||
|
|
||||||
|
if (!Yap_TrueFileName(libs->s, Yap_FileNameBuf, TRUE)) {
|
||||||
|
/* use LD_LIBRARY_PATH */
|
||||||
|
strncpy(Yap_FileNameBuf, libs->s, YAP_FILENAME_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __osf__
|
||||||
|
if((libs->handle=dlopen(Yap_FileNameBuf,RTLD_LAZY)) == NULL)
|
||||||
|
#else
|
||||||
|
if((libs->handle=dlopen(Yap_FileNameBuf,RTLD_LAZY|RTLD_GLOBAL)) == NULL)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
strcpy(Yap_ErrorSay,dlerror());
|
||||||
|
fprintf(stderr,"f=%s\n",Yap_ErrorSay);
|
||||||
|
return LOAD_FAILLED;
|
||||||
|
}
|
||||||
|
libs = libs->next;
|
||||||
|
}
|
||||||
|
|
||||||
while (ofiles) {
|
while (ofiles) {
|
||||||
void *handle;
|
void *handle;
|
||||||
|
|
||||||
|
/* load libraries first so that their symbols are available to
|
||||||
|
other routines */
|
||||||
|
|
||||||
/* dlopen wants to follow the LD_CONFIG_PATH */
|
/* dlopen wants to follow the LD_CONFIG_PATH */
|
||||||
if (!Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE)) {
|
if (!Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE)) {
|
||||||
strcpy(Yap_ErrorSay, "%% Trying to open unexisting file in LoadForeign");
|
strcpy(Yap_ErrorSay, "%% Trying to open unexisting file in LoadForeign");
|
||||||
@ -76,29 +99,6 @@ LoadForeign(StringList ofiles, StringList libs,
|
|||||||
return LOAD_FAILLED;
|
return LOAD_FAILLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load libraries first so that their symbols are available to
|
|
||||||
other routines */
|
|
||||||
while (libs) {
|
|
||||||
|
|
||||||
if (libs->s[0] == '-') {
|
|
||||||
strcpy(Yap_FileNameBuf,"lib");
|
|
||||||
strcat(Yap_FileNameBuf,libs->s+2);
|
|
||||||
strcat(Yap_FileNameBuf,".so");
|
|
||||||
} else {
|
|
||||||
strcpy(Yap_FileNameBuf,libs->s);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __osf__
|
|
||||||
if((libs->handle=dlopen(Yap_FileNameBuf,RTLD_LAZY)) == NULL)
|
|
||||||
#else
|
|
||||||
if((libs->handle=dlopen(Yap_FileNameBuf,RTLD_LAZY|RTLD_GLOBAL)) == NULL)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
strcpy(Yap_ErrorSay,dlerror());
|
|
||||||
return LOAD_FAILLED;
|
|
||||||
}
|
|
||||||
libs = libs->next;
|
|
||||||
}
|
|
||||||
return LOAD_SUCCEEDED;
|
return LOAD_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
<h2>Yap-5.1.2:</h2>
|
<h2>Yap-5.1.2:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li> NEW: matlab interface.</li>
|
||||||
|
<li> FIXED: search for libraries right.</li>
|
||||||
<li> FIXED: alarm used alarm(2) but it should use setitimer(2) so that
|
<li> FIXED: alarm used alarm(2) but it should use setitimer(2) so that
|
||||||
timeout can work with millisecs (obs from Bernd Gutmann).</li>
|
timeout can work with millisecs (obs from Bernd Gutmann).</li>
|
||||||
<li> FIXED: add . to -g goal (obs from Paulo Moura).</li>
|
<li> FIXED: add . to -g goal (obs from Paulo Moura).</li>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
:- ensure_loaded(library(lists)).
|
:- ensure_loaded(library(lists)).
|
||||||
|
|
||||||
:- load_foreign_files([matlab], ['/s/pkg/matlab/7r14sp3/bin/glnx86/libeng.so','/s/pkg/matlab/7r14sp3/bin/glnx86/libmx.so','/s/pkg/matlab/7r14sp3/bin/glnx86/libut.so'], init_matlab).
|
:- load_foreign_files([matlab], ['eng','mx','ut'], init_matlab).
|
||||||
|
|
||||||
matlab_eval_sequence(S) :-
|
matlab_eval_sequence(S) :-
|
||||||
atomic_concat(S,S1),
|
atomic_concat(S,S1),
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
load_foreign_files(Objs,Libs,Entry) :-
|
load_foreign_files(Objs,Libs,Entry) :-
|
||||||
'$check_objs_for_load_foreign_files'(Objs,NewObjs,load_foreign_files(Objs,Libs,Entry)),
|
'$check_objs_for_load_foreign_files'(Objs,NewObjs,load_foreign_files(Objs,Libs,Entry)),
|
||||||
'$check_libs_for_load_foreign_files'(Libs,load_foreign_files(Objs,Libs,Entry)),
|
'$check_libs_for_load_foreign_files'(Libs,NewLibs,load_foreign_files(Objs,Libs,Entry)),
|
||||||
'$check_entry_for_load_foreign_files'(Entry,load_foreign_files(Objs,Libs,Entry)),
|
'$check_entry_for_load_foreign_files'(Entry,load_foreign_files(Objs,Libs,Entry)),
|
||||||
'$load_foreign_files'(NewObjs,Libs,Entry).
|
'$load_foreign_files'(NewObjs,NewLibs,Entry).
|
||||||
|
|
||||||
'$check_objs_for_load_foreign_files'(V,_,G) :- var(V), !,
|
'$check_objs_for_load_foreign_files'(V,_,G) :- var(V), !,
|
||||||
'$do_error'(instantiation_error,G).
|
'$do_error'(instantiation_error,G).
|
||||||
@ -39,21 +39,48 @@ load_foreign_files(Objs,Libs,Entry) :-
|
|||||||
'$check_obj_for_load_foreign_files'(Obj,_,G) :-
|
'$check_obj_for_load_foreign_files'(Obj,_,G) :-
|
||||||
'$do_error'(type_error(atom,Obj),G).
|
'$do_error'(type_error(atom,Obj),G).
|
||||||
|
|
||||||
'$check_libs_for_load_foreign_files'(V,G) :- var(V), !,
|
'$check_libs_for_load_foreign_files'(V,_,G) :- var(V), !,
|
||||||
'$do_error'(instantiation_error,G).
|
'$do_error'(instantiation_error,G).
|
||||||
'$check_libs_for_load_foreign_files'([],_) :- !.
|
'$check_libs_for_load_foreign_files'([],[],_) :- !.
|
||||||
'$check_libs_for_load_foreign_files'([Lib|Libs],G) :- !,
|
'$check_libs_for_load_foreign_files'([Lib|Libs],[NLib|NLibs],G) :- !,
|
||||||
'$check_lib_for_load_foreign_files'(Lib,G),
|
'$check_lib_for_load_foreign_files'(Lib,NLib,G),
|
||||||
'$check_libs_for_load_foreign_files'(Libs,G).
|
'$check_libs_for_load_foreign_files'(Libs,NLibs,G).
|
||||||
'$check_libs_for_load_foreign_files'(Libs,G) :-
|
'$check_libs_for_load_foreign_files'(Libs,_,G) :-
|
||||||
'$do_error'(type_error(list,Libs),G).
|
'$do_error'(type_error(list,Libs),G).
|
||||||
|
|
||||||
'$check_lib_for_load_foreign_files'(V,G) :- var(V), !,
|
'$check_lib_for_load_foreign_files'(V,_,G) :- var(V), !,
|
||||||
'$do_error'(instantiation_error,G).
|
'$do_error'(instantiation_error,G).
|
||||||
'$check_lib_for_load_foreign_files'(Lib,_) :- atom(Lib), !.
|
'$check_lib_for_load_foreign_files'(Lib,NLib,_) :- atom(Lib), !,
|
||||||
'$check_lib_for_load_foreign_files'(Lib,G) :-
|
atom_codes(Lib,LibCodes),
|
||||||
|
'$process_obj_suffix'(LibCodes,NewLibCodes),
|
||||||
|
'$checklib_prefix'(NewLibCodes,FullLibCodes),
|
||||||
|
atom_codes(NLib,FullLibCodes).
|
||||||
|
'$check_lib_for_load_foreign_files'(Lib,_,G) :-
|
||||||
'$do_error'(type_error(atom,Lib),G).
|
'$do_error'(type_error(atom,Lib),G).
|
||||||
|
|
||||||
|
'$process_obj_suffix'(ObjCodes,ObjCodes) :-
|
||||||
|
'$obj_suffix'(ObjSuffix),
|
||||||
|
'$append'(_,ObjSuffix,ObjCodes), !.
|
||||||
|
'$process_obj_suffix'(ObjCodes,NewObjCodes) :-
|
||||||
|
'$obj_suffix'(ObjSuffix),
|
||||||
|
'$append'(ObjCodes,ObjSuffix,NewObjCodes).
|
||||||
|
|
||||||
|
'$checklib_prefix'(Cs,Cs) :- '$rooted_path'(Cs), !.
|
||||||
|
'$checklib_prefix'([0'l,0'i,0'b|NewObjCodes],[0'l,0'i,0'b|NewObjCodes]) :- !.
|
||||||
|
'$checklib_prefix'(NewObjCodes,[0'l,0'i,0'b|NewObjCodes]).
|
||||||
|
|
||||||
|
'$rooted_path'([C|_]) :- '$dir_separator'(C), !.
|
||||||
|
'$rooted_path'(Cs) :-
|
||||||
|
% win32 machine
|
||||||
|
'$dir_separator'(0'\\),
|
||||||
|
'$get_drive'(Cs).
|
||||||
|
|
||||||
|
'$get_drive'([0':|_]) :- !.
|
||||||
|
'$get_drive'([0'\\|_]) :- !, fail.
|
||||||
|
'$get_drive'([_|L]) :-
|
||||||
|
'$get_drive'(L).
|
||||||
|
|
||||||
|
|
||||||
'$check_entry_for_load_foreign_files'(V,G) :- var(V), !,
|
'$check_entry_for_load_foreign_files'(V,G) :- var(V), !,
|
||||||
'$do_error'(instantiation_error,G).
|
'$do_error'(instantiation_error,G).
|
||||||
'$check_entry_for_load_foreign_files'(Entry,_) :- atom(Entry), !.
|
'$check_entry_for_load_foreign_files'(Entry,_) :- atom(Entry), !.
|
||||||
@ -61,11 +88,5 @@ load_foreign_files(Objs,Libs,Entry) :-
|
|||||||
'$do_error'(type_error(atom,Entry),G).
|
'$do_error'(type_error(atom,Entry),G).
|
||||||
|
|
||||||
|
|
||||||
'$process_obj_suffix'(ObjCodes,ObjCodes) :-
|
|
||||||
'$obj_suffix'(ObjSuffix),
|
|
||||||
'$append'(ObjCodes,ObjSuffix,ObjCodes), !.
|
|
||||||
'$process_obj_suffix'(ObjCodes,NewObjCodes) :-
|
|
||||||
'$obj_suffix'(ObjSuffix),
|
|
||||||
'$append'(ObjCodes,ObjSuffix,NewObjCodes).
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user