$OpenBSD: patch-wxpython_cpp,v 1.1.1.1 2013/04/04 14:15:23 bcallah Exp $ We need to load libutil before libpython to prevent /usr/local/lib/libpythonX.Y.so.X.Y: undefined symbol 'forkpty' /usr/local/lib/libpythonX.Y.so.X.Y: undefined symbol 'openpty' --- wxpython.cpp.orig Tue Jun 12 20:04:44 2012 +++ wxpython.cpp Thu Feb 21 21:17:47 2013 @@ -257,6 +257,8 @@ static void GetPythonExceptions() Py_XDECREF(exmod); } +// handle for libutil +static wxDllType libutildll = NULL; // handle for Python lib static wxDllType pythondll = NULL; @@ -266,15 +268,37 @@ static void FreePythonLib() wxDynamicLibrary::Unload(pythondll); pythondll = NULL; } + + if ( libutildll ) { + wxDynamicLibrary::Unload(libutildll); + libutildll = NULL; + } } static bool LoadPythonLib() { + // load libutil + wxDynamicLibrary dynlibUtil; // load the Python library wxDynamicLibrary dynlib; // don't log errors in here wxLogNull noLog; + + // Load libutil first, needed for openpty() and forkpty() symbols + if ( !dynlibUtil.Load(wxT("libutil.so"), wxDL_NOW | wxDL_VERBATIM | wxDL_GLOBAL) ) { + return false; + } + + if ( dynlibUtil.IsLoaded() ) { + libutildll = dynlibUtil.Detach(); + } + + if ( libutildll == NULL ) { + // should never happen + Warning(_("Oh dear, libutil is not loaded!")); + return false; + } // wxDL_GLOBAL corresponds to RTLD_GLOBAL on Linux (ignored on Windows) and // is needed to avoid an ImportError when importing some modules (eg. time)