From b1c031d26b0e94570511acfdb0dfb8a43f0f6e58 Mon Sep 17 00:00:00 2001 From: "Tim D. Smith" Date: Mon, 4 May 2015 22:15:19 -0700 Subject: [PATCH] Don't explicitly link python on darwin Passing -undefined dynamic_lookup to the linker (instead of -lpython or -framework Python) permits undefined symbols in shared libraries on OS X. This allows a module to be linked against one Python framework and imported from another. --- src/tools/python.jam | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/tools/python.jam b/src/tools/python.jam index 1a41a1e86..90377eaae 100644 --- a/src/tools/python.jam +++ b/src/tools/python.jam @@ -962,16 +962,18 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? : # symbols. If we linked to libpython, we would get duplicate symbols. So # declare two targets -- one for building extensions and another for # embedding. - # - # Unlike most *nix systems, Mac OS X's linker does not permit undefined - # symbols when linking a shared library. So, we still need to link against - # the Python framework, even when building extensions. Note that framework - # builds of Python always use shared libraries, so we do not need to worry - # about duplicate Python symbols. - if $(target-os) in windows cygwin darwin + if $(target-os) in windows cygwin { alias python_for_extensions : python : $(target-requirements) ; } + else if $(target-os) = darwin { + alias python_for_extensions + : + : $(target-requirements) + : + : $(usage-requirements) "-undefined dynamic_lookup" + ; + } # On AIX we need Python extensions and Boost.Python to import symbols from # the Python interpreter. Dynamic libraries opened with dlopen() do not # inherit the symbols from the Python interpreter.