问题扩展Python(链接错误)?

时间:2009-03-21 08:23:00

标签: python c visual-studio visual-studio-2008 linker

我已经安装了Python 3k(C:\ Python30)和Visual Studio Professional Edition 2008。

我正在学习 this

这是一个问题:

C:\hello>dir
 Volume in drive C has no label.
 Volume Serial Number is 309E-14FB

 Directory of C:\hello

03/21/2009  01:15 AM    <DIR>          .
03/21/2009  01:15 AM    <DIR>          ..
03/21/2009  01:14 AM               481 hellomodule.c
               1 File(s)            481 bytes
               2 Dir(s)  10,640,642,048 bytes free


C:\hello>cl /LD hellomodule.c /Ic:\Python30\include c:\Python30\libs\python30.lib /link/out:hello.
dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

hellomodule.c
c:\hello\hellomodule.c(26) : warning C4716: 'inithello' : must return a value
Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:hellomodule.dll
/dll
/implib:hellomodule.lib
/out:hello.dll
hellomodule.obj
c:\Python30\libs\python30.lib
   Creating library hellomodule.lib and object hellomodule.exp
hellomodule.obj : error LNK2019: unresolved external symbol _Py_InitModule referenced in function
_inithello
hello.dll : fatal error LNK1120: 1 unresolved externals

C:\hello>

有什么问题?请指导我。

1 个答案:

答案 0 :(得分:2)

如果在c:\python30中安装了Python,为什么要在c:\Python24\libs\python30中搜索库?

现在你已经改变了问题来解决这个问题: - ),

我认为Py_InitModule不再可用了,你必须使用PyModule_Create(这可能是因为Py3k的早期测试版本,这是我最后一次看的时候)。

基于你的评论,大卫,我建议你需要避免官方Python文档以外的HowTo网站(我怀疑它们已经过时了)。在3.0级别的扩展接口上发生了很多工作,最好看的地方也是 在3.0 docs3.1 alpha docs

特定的Windows构建说明为here

相关问题