<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <link rel="STYLESHEET" href="ext.css" type='text/css' /> <link rel="SHORTCUT ICON" href="../icons/pyfav.gif" /> <link rel='start' href='../index.html' title='Python Documentation Index' /> <link rel="first" href="ext.html" title='Extending and Embedding the Python Interpreter' /> <link rel='contents' href='contents.html' title="Contents" /> <link rel='last' href='about.html' title='About this document...' /> <link rel='help' href='about.html' title='About this document...' /> <LINK rel="prev" href="embeddingInCplusplus.html"> <LINK rel="parent" href="embedding.html"> <LINK rel="next" href="reporting-bugs.html"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name='aesop' content='information' /> <META name="description" content="Linking Requirements "> <META name="keywords" content="ext"> <META name="resource-type" content="document"> <META name="distribution" content="global"> <title>5.6 Linking Requirements </title> </head> <body> <DIV CLASS="navigation"> <div id='top-navigation-panel'> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td class='online-navigation'><a rel="prev" title="5.5 Embedding Python in" href="embeddingInCplusplus.html"><img src='../icons/previous.png' border='0' height='32' alt='Previous Page' width='32' /></A></td> <td class='online-navigation'><a rel="parent" title="5. Embedding Python in" href="embedding.html"><img src='../icons/up.png' border='0' height='32' alt='Up One Level' width='32' /></A></td> <td class='online-navigation'><a rel="next" title="A. Reporting Bugs" href="reporting-bugs.html"><img src='../icons/next.png' border='0' height='32' alt='Next Page' width='32' /></A></td> <td align="center" width="100%">Extending and Embedding the Python Interpreter</td> <td class='online-navigation'><a rel="contents" title="Table of Contents" href="contents.html"><img src='../icons/contents.png' border='0' height='32' alt='Contents' width='32' /></A></td> <td class='online-navigation'><img src='../icons/blank.png' border='0' height='32' alt='' width='32' /></td> <td class='online-navigation'><img src='../icons/blank.png' border='0' height='32' alt='' width='32' /></td> </tr></table> <div class='online-navigation'> <b class="navlabel">Previous:</b> <a class="sectref" rel="prev" href="embeddingInCplusplus.html">5.5 Embedding Python in</A> <b class="navlabel">Up:</b> <a class="sectref" rel="parent" href="embedding.html">5. Embedding Python in</A> <b class="navlabel">Next:</b> <a class="sectref" rel="next" href="reporting-bugs.html">A. Reporting Bugs</A> </div> <hr /></div> </DIV> <!--End of Navigation Panel--> <H1><A NAME="SECTION007600000000000000000"><!--x--></A><A NAME="link-reqs"><!--z--></A> <BR> 5.6 Linking Requirements </H1> <P> While the <b class="program">configure</b> script shipped with the Python sources will correctly build Python to export the symbols needed by dynamically linked extensions, this is not automatically inherited by applications which embed the Python library statically, at least on <font style="font-variant: small-caps;">Unix</font>. This is an issue when the application is linked to the static runtime library (<span class="file">libpython.a</span>) and needs to load dynamic extensions (implemented as <span class="file">.so</span> files). <P> The problem is that some entry points are defined by the Python runtime solely for extension modules to use. If the embedding application does not use any of these entry points, some linkers will not include those entries in the symbol table of the finished executable. Some additional options are needed to inform the linker not to remove these symbols. <P> Determining the right options to use for any given platform can be quite difficult, but fortunately the Python configuration already has those values. To retrieve them from an installed Python interpreter, start an interactive interpreter and have a short session like this: <P> <div class="verbatim"><pre> >>> import distutils.sysconfig >>> distutils.sysconfig.get_config_var('LINKFORSHARED') '-Xlinker -export-dynamic' </pre></div> <a id='l2h-15'><!--x--></a> <P> The contents of the string presented will be the options that should be used. If the string is empty, there's no need to add any additional options. The <tt class="constant">LINKFORSHARED</tt> definition corresponds to the variable of the same name in Python's top-level <span class="file">Makefile</span>. <P> <DIV CLASS="navigation"> <div class='online-navigation'><hr /> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td class='online-navigation'><a rel="prev" title="5.5 Embedding Python in" rel="prev" title="5.5 Embedding Python in" href="embeddingInCplusplus.html"><img src='../icons/previous.png' border='0' height='32' alt='Previous Page' width='32' /></A></td> <td class='online-navigation'><a rel="parent" title="5. Embedding Python in" rel="parent" title="5. Embedding Python in" href="embedding.html"><img src='../icons/up.png' border='0' height='32' alt='Up One Level' width='32' /></A></td> <td class='online-navigation'><a rel="next" title="A. Reporting Bugs" rel="next" title="A. Reporting Bugs" href="reporting-bugs.html"><img src='../icons/next.png' border='0' height='32' alt='Next Page' width='32' /></A></td> <td align="center" width="100%">Extending and Embedding the Python Interpreter</td> <td class='online-navigation'><a rel="contents" title="Table of Contents" rel="contents" title="Table of Contents" href="contents.html"><img src='../icons/contents.png' border='0' height='32' alt='Contents' width='32' /></A></td> <td class='online-navigation'><img src='../icons/blank.png' border='0' height='32' alt='' width='32' /></td> <td class='online-navigation'><img src='../icons/blank.png' border='0' height='32' alt='' width='32' /></td> </tr></table> <div class='online-navigation'> <b class="navlabel">Previous:</b> <a class="sectref" rel="prev" href="embeddingInCplusplus.html">5.5 Embedding Python in</A> <b class="navlabel">Up:</b> <a class="sectref" rel="parent" href="embedding.html">5. Embedding Python in</A> <b class="navlabel">Next:</b> <a class="sectref" rel="next" href="reporting-bugs.html">A. Reporting Bugs</A> </div> </div> <hr /> <span class="release-info">Release 2.3.4, documentation updated on May 20, 2004.</span> </DIV> <!--End of Navigation Panel--> <ADDRESS> See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. </ADDRESS> </BODY> </HTML>