Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / html / python / ext / win-dlls.html
CommitLineData
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="dynamic-linking.html" />
12<link rel="parent" href="building-on-windows.html" />
13<link rel="next" href="embedding.html" />
14<meta name='aesop' content='information' />
15<title>4.3 Using DLLs in Practice </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="4.2 Differences Between Unix"
23 href="dynamic-linking.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="4. Building C and"
26 href="building-on-windows.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="5. Embedding Python in"
29 href="embedding.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="dynamic-linking.html">4.2 Differences Between Unix</A>
43<b class="navlabel">Up:</b>
44<a class="sectref" rel="parent" href="building-on-windows.html">4. Building C and</A>
45<b class="navlabel">Next:</b>
46<a class="sectref" rel="next" href="embedding.html">5. Embedding Python in</A>
47</div>
48<hr /></div>
49</DIV>
50<!--End of Navigation Panel-->
51
52<H1><A NAME="SECTION006300000000000000000"></A><A NAME="win-dlls"></A>
53<BR>
544.3 Using DLLs in Practice
55</H1>
56
57<P>
58Windows Python is built in Microsoft Visual C++; using other
59compilers may or may not work (though Borland seems to). The rest of
60this section is MSVC++ specific.
61
62<P>
63When creating DLLs in Windows, you must pass <span class="file">pythonXY.lib</span> to
64the linker. To build two DLLs, spam and ni (which uses C functions
65found in spam), you could use these commands:
66
67<P>
68<div class="verbatim"><pre>
69cl /LD /I/python/include spam.c ../libs/pythonXY.lib
70cl /LD /I/python/include ni.c spam.lib ../libs/pythonXY.lib
71</pre></div>
72
73<P>
74The first command created three files: <span class="file">spam.obj</span>,
75<span class="file">spam.dll</span> and <span class="file">spam.lib</span>. <span class="file">Spam.dll</span> does not contain
76any Python functions (such as <tt class="cfunction">PyArg_ParseTuple()</tt>), but it
77does know how to find the Python code thanks to <span class="file">pythonXY.lib</span>.
78
79<P>
80The second command created <span class="file">ni.dll</span> (and <span class="file">.obj</span> and
81<span class="file">.lib</span>), which knows how to find the necessary functions from
82spam, and also from the Python executable.
83
84<P>
85Not every identifier is exported to the lookup table. If you want any
86other modules (including Python) to be able to see your identifiers,
87you have to say "<tt class="samp">_declspec(dllexport)</tt>", as in "<tt class="samp">void
88_declspec(dllexport) initspam(void)</tt>" or "<tt class="samp">PyObject
89_declspec(dllexport) *NiGetSpamData(void)</tt>".
90
91<P>
92Developer Studio will throw in a lot of import libraries that you do
93not really need, adding about 100K to your executable. To get rid of
94them, use the Project Settings dialog, Link tab, to specify
95<em>ignore default libraries</em>. Add the correct
96<span class="file">msvcrt<var>xx</var>.lib</span> to the list of libraries.
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="4.2 Differences Between Unix"
104 href="dynamic-linking.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="4. Building C and"
107 href="building-on-windows.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="5. Embedding Python in"
110 href="embedding.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="dynamic-linking.html">4.2 Differences Between Unix</A>
124<b class="navlabel">Up:</b>
125<a class="sectref" rel="parent" href="building-on-windows.html">4. Building C and</A>
126<b class="navlabel">Next:</b>
127<a class="sectref" rel="next" href="embedding.html">5. Embedding Python in</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>
135See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
136</ADDRESS>
137</BODY>
138</HTML>