Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
扩展Python时出现问题(链接错误)?_Python_C_Visual Studio_Visual Studio 2008_Linker - Fatal编程技术网

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

扩展Python时出现问题(链接错误)?,python,c,visual-studio,visual-studio-2008,linker,Python,C,Visual Studio,Visual Studio 2008,Linker,我已经安装了Python3K(C:\Python30)和VisualStudioProfessionalEdition 2008 我在学习 这里有一个问题: 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:

我已经安装了Python3K(C:\Python30)和VisualStudioProfessionalEdition 2008

我在学习

这里有一个问题:

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>
C:\hello>dir
驱动器C中的卷没有标签。
卷序列号为309E-14FB
C:\hello目录
03/21/2009 01:15上午。
03/21/2009 01:15上午。。
03/21/2009 01:14 AM 481 hellomodule.c
1个文件481字节
2个目录(s)10640642048个可用字节
C:\hello>cl/LD hellomodule.C/Ic:\Python30\include C:\Python30\libs\Python30.lib/link/out:hello。
动态链接库
针对80x86的Microsoft(R)32位C/C++优化编译器版本15.00.21022.08
版权所有(C)微软公司。版权所有。
hellomodule.c
c:\hello\hellomodule.c(26):警告C4716:“inithello”:必须返回一个值
Microsoft(R)增量链接器版本9.00.21022.08
版权所有(C)微软公司。版权所有。
/输出:hellomodule.dll
/动态链接库
/implib:hellomodule.lib
/输出:hello.dll
hellomodule.obj
c:\Python30\libs\Python30.lib
创建库hellomodule.lib和对象hellomodule.exp
hellomodule.obj:错误LNK2019:函数中引用的未解析外部符号_Py_InitModule
_你好
hello.dll:致命错误LNK1120:1未解析的外部
C:\hello>

有什么问题?请指导我。

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

现在您已经更改了问题以解决此问题:-)

我认为不再提供
Py_InitModule
,您必须使用
PyModule\u Create
(这可能是自上次查看Py3k的早期beta以来发生的变化)

基于您的评论,David,我建议您避免使用官方Python文档之外的HowTo站点(我怀疑它们已经过时了)。在3.0版本的扩展接口上进行了大量的工作,最好的方法是 在手术室


具体的Windows构建说明是。

Cool,它生成了hello.dll,现在,我应该如何导入它?(我尝试导入hello)。但是没有名为hello的模块。注意:我刚刚用PyModule\u Create替换了Py\u InitModule。这样做可以吗?或者我还需要其他什么。我不确定这是否会有帮助。我为一个朋友做了一个编译扩展的屏幕广播。这是VS2003。