【发布时间】:2017-09-19 00:24:00
【问题描述】:
当我按照Creating a C++ extension for Python 的说明进行操作时,直到我到达将 C++ 项目转换为 Python 的扩展部分之前都没有收到任何错误。
在我完成本节中的步骤并尝试构建解决方案后,我偶然发现:
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 步。但我真的不知道如何处理。有什么建议吗?
我使用 x64 Windows 10。
【问题讨论】:
标签: python c++ python-3.x visual-studio-2017