classification
Title: Unresolved symbols in Windows 64-bit python
Type: compile error Stage:
Components: Build, Windows Versions: Python 3.3, Python 3.2, Python 2.7
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: brian.curtin, loewis, silverbacknet, spatz123
Priority: normal Keywords:

Created on 2012-08-23 20:38 by spatz123, last changed 2012-10-22 13:46 by loewis. This issue is now closed.

Messages (4)
msg168964 - (view) Author: Saul Spatz (spatz123) Date: 2012-08-23 20:38
In trying to build a SWING module on Windows with 64-bit python, I get the linker errors listed at the bottom of this message.

I have this problem with both python 2.7 and 3.2.  I have built the project without problems on Windows with 32-bit python, and a correspondent informs me that it cam be built on linux with 64-bit python.

I have listed the exports from python32.lib with dumpbin, and in every case, the symbol after the __imp__ appears in the library without a leading underscore. For example, for the first unresolved symbol, __imp__PyBytes_AsStringAndSize, I find that PyBytes_AsStringAndSize appears in the library.  Of 1074 exports in the library, 891 do not have leading underscores, and the remainder do.  In the 32-bit library, every export starts with an underscore.   

This is obviously related to issues 15165 and 14286, but I hope this additional information will help locate the trouble.  I am running windows 7 professional, and I installed python by downloading and running the installer with all the defaults.

1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyBytes_AsStringAndSize referenced in function _SWIG_Python_str_AsChar
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyUnicodeUCS2_AsUTF8String referenced in function _SWIG_Python_str_AsChar
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyUnicodeUCS2_FromString referenced in function _SWIG_Python_str_FromChar
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyExc_RuntimeError
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyExc_AttributeError
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyExc_SystemError
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyExc_ValueError
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyExc_SyntaxError
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyExc_OverflowError
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyExc_ZeroDivisionError
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyExc_TypeError
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyExc_IndexError
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyExc_IOError
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyExc_MemoryError
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyInstanceMethod_New referenced in function _SWIG_PyInstanceMethod_New
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyErr_SetString referenced in function _SWIG_Python_SetErrorMsg
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__Py_BuildValue referenced in function __SWIG_Py_None
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyLong_FromVoidPtr referenced in function _SwigPyObject_long
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__Py_DecRef referenced in function _SwigPyObject_repr
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyUnicodeUCS2_Concat referenced in function _SwigPyObject_repr
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyUnicodeUCS2_FromFormat referenced in function _SwigPyObject_repr
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyBool_FromLong referenced in function _SwigPyObject_richcompare
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp___Py_NotImplementedStruct
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyObject_Free referenced in function _SwigPyObject_dealloc
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyObject_CallFunctionObjArgs referenced in function _SwigPyObject_dealloc
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyObject_IsTrue referenced in function _SwigPyObject_own
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyArg_UnpackTuple referenced in function _SwigPyObject_own
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyType_Ready referenced in function _SwigPyObject_TypeOnce
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyObject_GenericGetAttr referenced in function _SwigPyObject_TypeOnce
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyBaseObject_Type
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyObject_SetAttr referenced in function _SWIG_Python_NewShadowInstance
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyObject_Call referenced in function _SWIG_Python_NewShadowInstance
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyErr_Clear referenced in function _SWIG_Python_GetModule
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyErr_Occurred referenced in function _SWIG_Python_GetModule
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyCapsule_Import referenced in function _SWIG_Python_GetModule
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyCapsule_GetPointer referenced in function _SWIG_Python_DestroyModule
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyModule_AddObject referenced in function _SWIG_Python_SetModule
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyCapsule_New referenced in function _SWIG_Python_SetModule
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyImport_AddModule referenced in function _SWIG_Python_SetModule
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyFloat_AsDouble referenced in function _SWIG_AsVal_double
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyLong_AsLong referenced in function _SWIG_AsVal_double
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyType_IsSubtype referenced in function _SWIG_AsVal_double
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyFloat_Type
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyLong_FromLong referenced in function _SWIG_From_int
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyArg_ParseTuple referenced in function __wrap_gcd
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyFloat_FromDouble referenced in function _Swig_var_Foo_get
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyUnicode_InternFromString referenced in function _swig_varlink_repr
1>example_wrap.obj : error LNK2001: unresolved external symbol __imp__PyExc_NameError
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyObject_Init referenced in function _SWIG_Python_newvarlink
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyObject_Malloc referenced in function _SWIG_Python_newvarlink
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp___PyObject_New referenced in function _SWIG_Python_NewPointerObj
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyDict_SetItemString referenced in function _SWIG_Python_InstallConstants
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyModule_GetDict referenced in function _PyInit__example
1>example_wrap.obj : error LNK2019: unresolved external symbol __imp__PyModule_Create2 referenced in function _PyInit__example
msg173419 - (view) Author: Silverback Networks (silverbacknet) Date: 2012-10-20 21:34
Same errors in 3.3. Some names are decorated, some aren't, seemingly at random.

For instance, python32.lib contains:

    35B20 _PyObject_Dump
    35B20 __imp__PyObject_Dump

and just below that,

    2924A PyObject_Free
    2924A __imp_PyObject_Free

But the Visual Studio 2010 compiler always looks for the underscored names for x64, resulting in, for instance:

  error LNK2019: unresolved external symbol __imp__PyObject_Free referenced in function _WRdealloc

I understand that the x64 isn't supposed to use underscore prefixes as all, but it is and Python partially is. I have no idea why.

The preprocessed output of including python.h, btw, is:

__declspec(dllimport) void PyObject_Free(void *);
msg173438 - (view) Author: Silverback Networks (silverbacknet) Date: 2012-10-21 09:41
Boy, do I feel like an idiot now. An update to VC 2010 Express SP1 had clobbered by x64 build capabilities completely, and even reinstalling the SDK did nothing. It turns out that there's a specific hotfix you have to install to get x64 builds working again: http://support.microsoft.com/kb/2519277

When I did that and fixed up the build environment variables, Python extensions all built again, despite the apparently random decorating.
msg173517 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-10-22 13:46
Closing as works-for-me then.
History
Date User Action Args
2012-10-22 13:46:25loewissetstatus: open -> closed
resolution: works for me
messages: + msg173517
2012-10-21 09:41:12silverbacknetsetmessages: + msg173438
2012-10-20 21:34:54silverbacknetsetversions: + Python 3.3
2012-10-20 21:34:36silverbacknetsetnosy: + silverbacknet
messages: + msg173419
2012-08-23 20:59:23brian.curtinsetnosy: + loewis, brian.curtin
components: + Build
2012-08-23 20:38:58spatz123create