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:
vsc
2007-05-24 19:54:45 +00:00
parent 244d4128cf
commit dc9ab3b1c7
4 changed files with 64 additions and 41 deletions

View File

@@ -44,9 +44,32 @@ LoadForeign(StringList ofiles, StringList libs,
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) {
void *handle;
/* load libraries first so that their symbols are available to
other routines */
/* dlopen wants to follow the LD_CONFIG_PATH */
if (!Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE)) {
strcpy(Yap_ErrorSay, "%% Trying to open unexisting file in LoadForeign");
@@ -76,29 +99,6 @@ LoadForeign(StringList ofiles, StringList libs,
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;
}