为Python创建C++扩展

2024-10-03 15:28:01 发布

您现在位置:Python中文网/ 问答频道 /正文

<>当我遵循从{a1}的指令时,直到到达eMe>的部分,才能得到任何错误。C++项目转换为Python EEEM的扩展。在

在我完成本节中的步骤并尝试构建解决方案之后,我无意中发现:

1>------ Build started: Project: CppMain, Configuration: Debug Win32 ------
1>module.cpp
1>   Creating library C:\Users\$andu\Desktop\Cpp4Py\Debug\Cpp4Py.lib and object C:\Users\$andu\Desktop\Cpp4Py\Debug\Cpp4Py.exp
1>module.obj : error LNK2019: unresolved external symbol __imp__PyFloat_FromDouble referenced in function "struct _object * __cdecl tanh(struct _object *,struct _object *)" (?tanh@@YAPAU_object@@PAU1@0@Z)
1>module.obj : error LNK2019: unresolved external symbol __imp__PyFloat_AsDouble referenced in function "struct _object * __cdecl tanh(struct _object *,struct _object *)" (?tanh@@YAPAU_object@@PAU1@0@Z)
1>module.obj : error LNK2019: unresolved external symbol __imp__PyModule_Create2 referenced in function _PyInit_Cpp4Py
1>C:\Python\Anaconda3\libs\python3.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
1>C:\Users\$andu\Desktop\Cpp4Py\Debug\Cpp4Py.pyd : fatal error LNK1120: 3 unresolved externals
1>Done building project "CppMain.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

从上面的消息来看,我怀疑问题来自于这组指令中的第2步。但我真的不知道该怎么处理。有什么建议吗?在


我用的是x64windows10。在


Tags: debugobjobjecterrorsymbolusersstructexternal
1条回答
网友
1楼 · 发布于 2024-10-03 15:28:01

我不确定。但您可以将项目的目标计算机类型更改为x64并重试。请参阅此警告:

C:\Python\Anaconda3\libs\python3.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'

相关问题 更多 >