擅长:python、mysql、java
<p>构建Python扩展的标准、可移植的方法是通过<a href="http://docs.python.org/distutils/setupscript.html#describing-extension-modules" rel="nofollow">distutils</a>。但是,VisualStudio2010不是Python2.7支持的编译器。以下内容设置.py适合我使用Visual Studio 2008和boost_1_48_0。构建命令是<code>python setup.py build_ext inplace</code>。</p>
<pre><code># setup.py
from distutils.core import setup
from distutils.extension import Extension
setup(name="getting_started1",
ext_modules=[
Extension("getting_started1", ["getting_started1.cpp"],
include_dirs=['boost_1_48_0'],
libraries = ['boost_python-vc90-mt-1_48'],
extra_compile_args=['/EHsc', '/FD', '/DBOOST_ALL_DYN_LINK=1']
)
])
</code></pre>
<p>对于VisualStudio2010项目,请尝试将链接器输出文件更改为<code>getting_started1.pyd</code>,而不是<code>myDLL.dll</code>。</p>