Sandu Ursu
Sandu Ursu

Reputation: 1261

Creating a C++ extension for Python

When I follow the instructions from Creating a C++ extension for Python I don't get any errors until I reach the section Convert the C++ project to an extension for Python.

After I go through the steps from this section and attempt to build the solution I stumble on this:

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 ==========

From the message above, I suspect that the problem comes from step 2 in that set of instructions. But I don't really know how to deal with that. Any suggestions?


I work with x64 Windows 10.

Upvotes: 1

Views: 8573

Answers (1)

Martin
Martin

Reputation: 61

I'm not sure. But you can change your project's target machine type to x64 and try again. See this warning:

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

Upvotes: 6

Related Questions