Commit | Line | Data |
---|---|---|
86530b38 AT |
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="prev" href="embeddingInCplusplus.html" /> | |
12 | <link rel="parent" href="embedding.html" /> | |
13 | <link rel="next" href="reporting-bugs.html" /> | |
14 | <meta name='aesop' content='information' /> | |
15 | <title>5.6 Linking Requirements </title> | |
16 | </head> | |
17 | <body> | |
18 | <DIV CLASS="navigation"> | |
19 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
20 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
21 | <tr> | |
22 | <td class='online-navigation'><a rel="prev" title="5.5 Embedding Python in" | |
23 | href="embeddingInCplusplus.html"><img src='../icons/previous.png' | |
24 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
25 | <td class='online-navigation'><a rel="parent" title="5. Embedding Python in" | |
26 | href="embedding.html"><img src='../icons/up.png' | |
27 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
28 | <td class='online-navigation'><a rel="next" title="A. Reporting Bugs" | |
29 | href="reporting-bugs.html"><img src='../icons/next.png' | |
30 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
31 | <td align="center" width="100%">Extending and Embedding the Python Interpreter</td> | |
32 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
33 | href="contents.html"><img src='../icons/contents.png' | |
34 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
35 | <td class='online-navigation'><img src='../icons/blank.png' | |
36 | border='0' height='32' alt='' width='32' /></td> | |
37 | <td class='online-navigation'><img src='../icons/blank.png' | |
38 | border='0' height='32' alt='' width='32' /></td> | |
39 | </tr></table> | |
40 | <div class='online-navigation'> | |
41 | <b class="navlabel">Previous:</b> | |
42 | <a class="sectref" rel="prev" href="embeddingInCplusplus.html">5.5 Embedding Python in</A> | |
43 | <b class="navlabel">Up:</b> | |
44 | <a class="sectref" rel="parent" href="embedding.html">5. Embedding Python in</A> | |
45 | <b class="navlabel">Next:</b> | |
46 | <a class="sectref" rel="next" href="reporting-bugs.html">A. Reporting Bugs</A> | |
47 | </div> | |
48 | <hr /></div> | |
49 | </DIV> | |
50 | <!--End of Navigation Panel--> | |
51 | ||
52 | <H1><A NAME="SECTION007600000000000000000"></A><A NAME="link-reqs"></A> | |
53 | <BR> | |
54 | 5.6 Linking Requirements | |
55 | ||
56 | </H1> | |
57 | ||
58 | <P> | |
59 | While the <b class="program">configure</b> script shipped with the Python sources | |
60 | will correctly build Python to export the symbols needed by | |
61 | dynamically linked extensions, this is not automatically inherited by | |
62 | applications which embed the Python library statically, at least on | |
63 | <span class="Unix">Unix</span>. This is an issue when the application is linked to the static | |
64 | runtime library (<span class="file">libpython.a</span>) and needs to load dynamic | |
65 | extensions (implemented as <span class="file">.so</span> files). | |
66 | ||
67 | <P> | |
68 | The problem is that some entry points are defined by the Python | |
69 | runtime solely for extension modules to use. If the embedding | |
70 | application does not use any of these entry points, some linkers will | |
71 | not include those entries in the symbol table of the finished | |
72 | executable. Some additional options are needed to inform the linker | |
73 | not to remove these symbols. | |
74 | ||
75 | <P> | |
76 | Determining the right options to use for any given platform can be | |
77 | quite difficult, but fortunately the Python configuration already has | |
78 | those values. To retrieve them from an installed Python interpreter, | |
79 | start an interactive interpreter and have a short session like this: | |
80 | ||
81 | <P> | |
82 | <div class="verbatim"><pre> | |
83 | >>> import distutils.sysconfig | |
84 | >>> distutils.sysconfig.get_config_var('LINKFORSHARED') | |
85 | '-Xlinker -export-dynamic' | |
86 | </pre></div> | |
87 | <a id='l2h-15' xml:id='l2h-15'></a> | |
88 | ||
89 | <P> | |
90 | The contents of the string presented will be the options that should | |
91 | be used. If the string is empty, there's no need to add any | |
92 | additional options. The <tt class="constant">LINKFORSHARED</tt> definition | |
93 | corresponds to the variable of the same name in Python's top-level | |
94 | <span class="file">Makefile</span>. | |
95 | ||
96 | <P> | |
97 | ||
98 | <DIV CLASS="navigation"> | |
99 | <div class='online-navigation'> | |
100 | <p></p><hr /> | |
101 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
102 | <tr> | |
103 | <td class='online-navigation'><a rel="prev" title="5.5 Embedding Python in" | |
104 | href="embeddingInCplusplus.html"><img src='../icons/previous.png' | |
105 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
106 | <td class='online-navigation'><a rel="parent" title="5. Embedding Python in" | |
107 | href="embedding.html"><img src='../icons/up.png' | |
108 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
109 | <td class='online-navigation'><a rel="next" title="A. Reporting Bugs" | |
110 | href="reporting-bugs.html"><img src='../icons/next.png' | |
111 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
112 | <td align="center" width="100%">Extending and Embedding the Python Interpreter</td> | |
113 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
114 | href="contents.html"><img src='../icons/contents.png' | |
115 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
116 | <td class='online-navigation'><img src='../icons/blank.png' | |
117 | border='0' height='32' alt='' width='32' /></td> | |
118 | <td class='online-navigation'><img src='../icons/blank.png' | |
119 | border='0' height='32' alt='' width='32' /></td> | |
120 | </tr></table> | |
121 | <div class='online-navigation'> | |
122 | <b class="navlabel">Previous:</b> | |
123 | <a class="sectref" rel="prev" href="embeddingInCplusplus.html">5.5 Embedding Python in</A> | |
124 | <b class="navlabel">Up:</b> | |
125 | <a class="sectref" rel="parent" href="embedding.html">5. Embedding Python in</A> | |
126 | <b class="navlabel">Next:</b> | |
127 | <a class="sectref" rel="next" href="reporting-bugs.html">A. Reporting Bugs</A> | |
128 | </div> | |
129 | </div> | |
130 | <hr /> | |
131 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
132 | </DIV> | |
133 | <!--End of Navigation Panel--> | |
134 | <ADDRESS> | |
135 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
136 | </ADDRESS> | |
137 | </BODY> | |
138 | </HTML> |