python.cpp: Importing binary Python extensions now works more reliably on Linux. Thanks to Phil Ashby for the patch!

This commit is contained in:
gergely.erdelyi 2009-05-21 19:28:13 +00:00
parent 791fde6af7
commit 097a6ae4b0

View File

@ -19,6 +19,9 @@
#include <stdio.h>
#include <string.h>
#ifdef __LINUX__
#include <dlfcn.h>
#endif
#include <ida.hpp>
#include <idp.hpp>
#include <ieee.h>
@ -618,6 +621,18 @@ bool IDAPython_Init(void)
return false;
}
#ifdef __LINUX__
/* Export symbols from libpython to resolve imported module deps */
qsnprintf(tmp, sizeof(tmp), "libpython%d.%d.so",
PY_MAJOR_VERSION,
PY_MINOR_VERSION);
if (!dlopen(tmp, RTLD_NOLOAD | RTLD_GLOBAL))
{
warning("IDAPython: dlopen(%s) failed", tmp);
return false;
}
#endif
/* Start the interpreter */
Py_Initialize();