[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dlopen question...
> This has nothing whatsoever to do with the additional leading
> underscore in symbol names for a.out. Please don't confuse the
> issue any further.
For what it's worth, I wrote this snippet of autoconf script some time
ago (actually, the full code also checks for HP-UX style libraries and
provides a dlfcn wrapper, but this is outside the scope of this topic).
Miod
myapp_dynload=no
myapp_dynload_underscores=no
myapp_dllib=
# Check for SunOS-style shared libraries
AC_CHECK_HEADERS(dlfcn.h)
if test $ac_cv_header_dlfcn_h = yes
then
AC_CHECK_LIB(c,dlopen,myapp_dynload=yes,
[AC_CHECK_LIB(dl,dlopen,[myapp_dynload=sun
myapp_dllib="-ldl"],myapp_dynload=no)])
fi
if test $myapp_dynload = yes
then
AC_CACHE_CHECK(
[wherever dynamically loaded symbols need underscores],
myapp_cv_dynload_underscores,
myapp_oldlibs=$LIBS
LIBS="$LIBS $myapp_dllib"
AC_LANG_SAVE
AC_LANG_C
AC_TRY_RUN([#include <dlfcn.h>
#ifndef RTLD_GLOBAL
#define RTLD_GLOBAL 0
#endif
int main(void)
{
void *libc, *printfptr;
libc = dlopen("libc.so", RTLD_LAZY | RTLD_GLOBAL);
if (!libc)
exit(1);
printfptr = dlsym(libc, "_printf");
dlclose(libc);
exit(!printfptr);
}],
myapp_cv_dynload_underscores=yes,
myapp_cv_dynload_underscores=no,
myapp_cv_dynload_underscores=no)
AC_LANG_RESTORE
LIBS=$myapp_oldlibs
)
if test $myapp_cv_dynload_underscores = yes
then
AC_DEFINE(DLSYM_NEEDS_UNDERSCORE)
fi
fi