| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="ext.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="ext.html" title='Extending and Embedding the Python Interpreter' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='last' href='about.html' title='About this document...' /> |
| 10 | <link rel='help' href='about.html' title='About this document...' /> |
| 11 | <link rel="next" href="callingPython.html" /> |
| 12 | <link rel="prev" href="methodTable.html" /> |
| 13 | <link rel="parent" href="intro.html" /> |
| 14 | <link rel="next" href="callingPython.html" /> |
| 15 | <meta name='aesop' content='information' /> |
| 16 | <title>1.5 Compilation and Linkage |
| 17 | </title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="1.4 The Module's Method" |
| 25 | href="methodTable.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="1. Extending Python with" |
| 28 | href="intro.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="1.6 Calling Python Functions" |
| 31 | href="callingPython.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Extending and Embedding the Python Interpreter</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><img src='../icons/blank.png' |
| 38 | border='0' height='32' alt='' width='32' /></td> |
| 39 | <td class='online-navigation'><img src='../icons/blank.png' |
| 40 | border='0' height='32' alt='' width='32' /></td> |
| 41 | </tr></table> |
| 42 | <div class='online-navigation'> |
| 43 | <b class="navlabel">Previous:</b> |
| 44 | <a class="sectref" rel="prev" href="methodTable.html">1.4 The Module's Method</A> |
| 45 | <b class="navlabel">Up:</b> |
| 46 | <a class="sectref" rel="parent" href="intro.html">1. Extending Python with</A> |
| 47 | <b class="navlabel">Next:</b> |
| 48 | <a class="sectref" rel="next" href="callingPython.html">1.6 Calling Python Functions</A> |
| 49 | </div> |
| 50 | <hr /></div> |
| 51 | </DIV> |
| 52 | <!--End of Navigation Panel--> |
| 53 | |
| 54 | <H1><A NAME="SECTION003500000000000000000"></A><A NAME="compilation"></A> |
| 55 | <BR> |
| 56 | 1.5 Compilation and Linkage |
| 57 | |
| 58 | </H1> |
| 59 | |
| 60 | <P> |
| 61 | There are two more things to do before you can use your new extension: |
| 62 | compiling and linking it with the Python system. If you use dynamic |
| 63 | loading, the details may depend on the style of dynamic loading your |
| 64 | system uses; see the chapters about building extension modules |
| 65 | (chapter <A href="building.html#building">3</A>) and additional information that pertains only |
| 66 | to building on Windows (chapter <A href="building-on-windows.html#building-on-windows">4</A>) for more |
| 67 | information about this. |
| 68 | |
| 69 | <P> |
| 70 | If you can't use dynamic loading, or if you want to make your module a |
| 71 | permanent part of the Python interpreter, you will have to change the |
| 72 | configuration setup and rebuild the interpreter. Luckily, this is |
| 73 | very simple on <span class="Unix">Unix</span>: just place your file (<span class="file">spammodule.c</span> for |
| 74 | example) in the <span class="file">Modules/</span> directory of an unpacked source |
| 75 | distribution, add a line to the file <span class="file">Modules/Setup.local</span> |
| 76 | describing your file: |
| 77 | |
| 78 | <P> |
| 79 | <div class="verbatim"><pre> |
| 80 | spam spammodule.o |
| 81 | </pre></div> |
| 82 | |
| 83 | <P> |
| 84 | and rebuild the interpreter by running <b class="program">make</b> in the toplevel |
| 85 | directory. You can also run <b class="program">make</b> in the <span class="file">Modules/</span> |
| 86 | subdirectory, but then you must first rebuild <span class="file">Makefile</span> |
| 87 | there by running `<b class="program">make</b> Makefile'. (This is necessary each |
| 88 | time you change the <span class="file">Setup</span> file.) |
| 89 | |
| 90 | <P> |
| 91 | If your module requires additional libraries to link with, these can |
| 92 | be listed on the line in the configuration file as well, for instance: |
| 93 | |
| 94 | <P> |
| 95 | <div class="verbatim"><pre> |
| 96 | spam spammodule.o -lX11 |
| 97 | </pre></div> |
| 98 | |
| 99 | <P> |
| 100 | |
| 101 | <DIV CLASS="navigation"> |
| 102 | <div class='online-navigation'> |
| 103 | <p></p><hr /> |
| 104 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 105 | <tr> |
| 106 | <td class='online-navigation'><a rel="prev" title="1.4 The Module's Method" |
| 107 | href="methodTable.html"><img src='../icons/previous.png' |
| 108 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 109 | <td class='online-navigation'><a rel="parent" title="1. Extending Python with" |
| 110 | href="intro.html"><img src='../icons/up.png' |
| 111 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 112 | <td class='online-navigation'><a rel="next" title="1.6 Calling Python Functions" |
| 113 | href="callingPython.html"><img src='../icons/next.png' |
| 114 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 115 | <td align="center" width="100%">Extending and Embedding the Python Interpreter</td> |
| 116 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 117 | href="contents.html"><img src='../icons/contents.png' |
| 118 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 119 | <td class='online-navigation'><img src='../icons/blank.png' |
| 120 | border='0' height='32' alt='' width='32' /></td> |
| 121 | <td class='online-navigation'><img src='../icons/blank.png' |
| 122 | border='0' height='32' alt='' width='32' /></td> |
| 123 | </tr></table> |
| 124 | <div class='online-navigation'> |
| 125 | <b class="navlabel">Previous:</b> |
| 126 | <a class="sectref" rel="prev" href="methodTable.html">1.4 The Module's Method</A> |
| 127 | <b class="navlabel">Up:</b> |
| 128 | <a class="sectref" rel="parent" href="intro.html">1. Extending Python with</A> |
| 129 | <b class="navlabel">Next:</b> |
| 130 | <a class="sectref" rel="next" href="callingPython.html">1.6 Calling Python Functions</A> |
| 131 | </div> |
| 132 | </div> |
| 133 | <hr /> |
| 134 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 135 | </DIV> |
| 136 | <!--End of Navigation Panel--> |
| 137 | <ADDRESS> |
| 138 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 139 | </ADDRESS> |
| 140 | </BODY> |
| 141 | </HTML> |