Index: /branches/cones-final/lib/callable/src/perl/Main.cc =================================================================== --- /branches/cones-final/lib/callable/src/perl/Main.cc (revision 10007) +++ /branches/cones-final/lib/callable/src/perl/Main.cc (revision 10396) @@ -23,4 +23,6 @@ #include #include + +#include #ifdef __APPLE__ @@ -91,4 +93,29 @@ Main::Main(const std::string& user_opts, const std::string& install_top, const std::string& install_arch) { + Dl_info dli; + void *polyhandle = NULL; + int dlreturn; + if(dlreturn = dladdr((void*)&destroy_perl, &dli)) { + polyhandle = dlopen(dli.dli_fname, RTLD_LAZY | RTLD_NOLOAD | RTLD_GLOBAL ); + } +#if POLYMAKE_DEBUG + if (!polyhandle) { + std::cerr << "*** WARNING: Failed to (re-)dlopen libpolymake with RTLD_GLOBAL: " + << (dlreturn ? dlerror() : "dladdr failed to give shared library pathname.") << "***" << std::endl; + std::cerr << " Application modules might fail to load." << std::endl; + } +#endif + void *perlhandle=NULL; + if(dlreturn = dladdr((void*)&perl_destruct, &dli)) { + perlhandle = dlopen(dli.dli_fname, RTLD_LAZY | RTLD_NOLOAD | RTLD_GLOBAL ); + } +#if POLYMAKE_DEBUG + if (!perlhandle) { + std::cerr << "*** WARNING: Failed to (re-)dlopen libperl with RTLD_GLOBAL: " + << (dlreturn ? dlerror() : "dladdr failed to give shared library pathname.") << "***" << std::endl; + std::cerr << " Perl modules might fail to load." << std::endl; + } +#endif + if (PL_curinterp != NULL) return; std::string script_arg(scr1);