Discussion:
[Cython] error LNK2001: unresolved external symbol PyInit_init
Andriy Kornatskyy
2014-08-14 05:20:03 UTC
Permalink
Here is an issue when trying to install wheezy.template (it uses cythonize) into environment with cython.

Host: windows 7 64bit Python version: 3.4.1 32 bit wheezy.template version: 0.1.151

When installing either from pip3 or downloading the source with python3 setup.py install

c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\Python34\libs /LIBPATH:C:\Python34\PCbuild /EXPORT: PyInit_init build\temp.win32-3.4\Release\src\wheezy\template__init.obj /O UT:build\lib.win32-3.4\wheezy\template__init.pyd /IMPLIB:build\temp.win32-3.4 \Release\src\wheezy\template__init.lib /MANIFESTFILE:build\temp.win32-3.4\Rel ease\src\wheezy\template__init.pyd.manifest
LINK : error LNK2001: unresolved external symbol PyInit_init
build\temp.win32-3.4\Release\src\wheezy\template__init__.lib : fatal error LNK1120: 1 unresolved externals
error: command 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe' failed with exit status 1120

Some details are here:
https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails

Thanks.

Andriy Kornatskyy
Sturla Molden
2014-08-20 17:25:22 UTC
Permalink
To build a Python extension for Win64 you must define the symbol MS_WIN64,
typically -DMS_WIN64.

Sturla
Post by Andriy Kornatskyy
Here is an issue when trying to install wheezy.template (it uses
cythonize) into environment with cython.
Host: windows 7 64bit Python version: 3.4.1 32 bit wheezy.template version: 0.1.151
When installing either from pip3 or downloading the source with python3 setup.py install
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe /DLL
/nologo /INCREMENTAL:NO /LIBPATH:C:\Python34\libs
/LIBPATH:C:\Python34\PCbuild /EXPORT: PyInit_init
build\temp.win32-3.4\Release\src\wheezy\template__init.obj /O
UT:build\lib.win32-3.4\wheezy\template__init.pyd
/IMPLIB:build\temp.win32-3.4 \Release\src\wheezy\template__init.lib
/MANIFESTFILE:build\temp.win32-3.4\Rel ease\src\wheezy\template__init.pyd.manifest
LINK : error LNK2001: unresolved external symbol PyInit_init
build\temp.win32-3.4\Release\src\wheezy\template__init__.lib : fatal
error LNK1120: 1 unresolved externals
error: command 'c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\BIN\link.exe' failed with exit status 1120
https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails
Thanks.
Andriy Kornatskyy
Lisandro Dalcin
2014-08-21 11:30:10 UTC
Permalink
Post by Sturla Molden
To build a Python extension for Win64 you must define the symbol MS_WIN64,
typically -DMS_WIN64.
Sturla, isn't this supposed to be handled in pyconfig.h (at least when
using MSVC) ? I see these lines in PC/pyconfig.h (from Python
sources):

/* MSVC defines _WINxx to differentiate the windows platform types

Note that for compatibility reasons _WIN32 is defined on Win32
*and* on Win64. For the same reasons, in Python, MS_WIN32 is
defined on Win32 *and* Win64. Win32 only code must therefore be
guarded as follows:
#if defined(MS_WIN32) && !defined(MS_WIN64)
Some modules are disabled on Itanium processors, therefore we
have MS_WINI64 set for those targets, otherwise MS_WINX64
*/
#ifdef _WIN64
#define MS_WIN64
#endif
--
Lisandro Dalcin
---------------
CIMEC (UNL/CONICET)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
3000 Santa Fe, Argentina
Tel: +54-342-4511594 (ext 1016)
Tel/Fax: +54-342-4511169
Sturla Molden
2014-08-23 18:17:26 UTC
Permalink
Post by Lisandro Dalcin
Sturla, isn't this supposed to be handled in pyconfig.h (at least when
using MSVC) ? I see these lines in PC/pyconfig.h (from Python
Yes, it is supposed to, but the error message suggest it was not and the
compile line does not have it.

Sturla
Lisandro Dalcin
2014-08-24 08:57:48 UTC
Permalink
Post by Andriy Kornatskyy
When installing either from pip3 or downloading the source with python3 setup.py install
Could you please show us the full output of "python3 setup.py build" ?
--
Lisandro Dalcin
============
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Numerical Porous Media Center (NumPor)
King Abdullah University of Science and Technology (KAUST)
http://numpor.kaust.edu.sa/

4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 4332
Thuwal 23955-6900, Kingdom of Saudi Arabia
http://www.kaust.edu.sa

Office Phone: +966 12 808-0459
Andriy Kornatskyy
2014-08-27 05:08:14 UTC
Permalink
Here is a link to complete output with python3.4:

https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152

Thanks.

Andriy Kornatskyy
Post by Lisandro Dalcin
Post by Andriy Kornatskyy
When installing either from pip3 or downloading the source with python3 setup.py install
Could you please show us the full output of "python3 setup.py build" ?
--
Lisandro Dalcin
============
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Numerical Porous Media Center (NumPor)
King Abdullah University of Science and Technology (KAUST)
http://numpor.kaust.edu.sa/
4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 4332
Thuwal 23955-6900, Kingdom of Saudi Arabia
http://www.kaust.edu.sa
Office Phone: +966 12 808-0459
_______________________________________________
cython-devel mailing list
https://mail.python.org/mailman/listinfo/cython-devel
Sturla Molden
2014-08-27 08:47:01 UTC
Permalink
64-bit Python cannot be used to build 32-bit extensions. Yes, you can build
extensions for 32-bit Python on 64-bit Windows, but not with 64-bit Python.

Sturla
Post by Andriy Kornatskyy
https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152
Thanks.
Andriy Kornatskyy
On Aug 24, 2014, at 11:57 AM, Lisandro Dalcin
On 14 August 2014 08:20, Andriy Kornatskyy
Post by Andriy Kornatskyy
When installing either from pip3 or downloading the source with python3 setup.py install
Could you please show us the full output of "python3 setup.py build" ?
--
Lisandro Dalcin
============
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Numerical Porous Media Center (NumPor)
King Abdullah University of Science and Technology (KAUST)
http://numpor.kaust.edu.sa/
4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 4332
Thuwal 23955-6900, Kingdom of Saudi Arabia
http://www.kaust.edu.sa
Office Phone: +966 12 808-0459
_______________________________________________
cython-devel mailing list
https://mail.python.org/mailman/listinfo/cython-devel
Andriy Kornatskyy
2014-08-27 14:20:06 UTC
Permalink
Sturla,

Per further details:
https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12018243

It is python 32 bit on 64 bit machine.

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (In
tel)] on win32

Thanks.

Andriy Kornatskyy
Post by Sturla Molden
64-bit Python cannot be used to build 32-bit extensions. Yes, you can build
extensions for 32-bit Python on 64-bit Windows, but not with 64-bit Python.
Sturla
Post by Andriy Kornatskyy
https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152
Thanks.
Andriy Kornatskyy
On Aug 24, 2014, at 11:57 AM, Lisandro Dalcin
On 14 August 2014 08:20, Andriy Kornatskyy
Post by Andriy Kornatskyy
When installing either from pip3 or downloading the source with python3 setup.py install
Could you please show us the full output of "python3 setup.py build" ?
--
Lisandro Dalcin
============
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Numerical Porous Media Center (NumPor)
King Abdullah University of Science and Technology (KAUST)
http://numpor.kaust.edu.sa/
4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 4332
Thuwal 23955-6900, Kingdom of Saudi Arabia
http://www.kaust.edu.sa
Office Phone: +966 12 808-0459
_______________________________________________
cython-devel mailing list
https://mail.python.org/mailman/listinfo/cython-devel
_______________________________________________
cython-devel mailing list
https://mail.python.org/mailman/listinfo/cython-devel
Stefan Behnel
2014-08-28 07:29:04 UTC
Permalink
Post by Andriy Kornatskyy
https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152
What Lisandro meant with "complete" is "from entering the build command to
the point where it fails".

Stefan
Andriy Kornatskyy
2014-08-28 08:08:37 UTC
Permalink
Stefan,

Hmm… you have a complete build log from the entering the build command up to the point where it fails which you can still find here:

https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152

Or am I missing something?

Thanks.

Andriy Kornatskyy
Post by Stefan Behnel
Post by Andriy Kornatskyy
https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152
What Lisandro meant with "complete" is "from entering the build command to
the point where it fails".
Stefan
_______________________________________________
cython-devel mailing list
https://mail.python.org/mailman/listinfo/cython-devel
Stefan Behnel
2014-08-28 10:46:46 UTC
Permalink
Post by Andriy Kornatskyy
https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152
Sorry, where? All I see is the command and then the linker command, no
Cython build call, no C compiler build call, no distutils output.

Stefan
Andriy Kornatskyy
2014-08-28 10:59:03 UTC
Permalink
Stefan,

That is an output of build:

python setup.py build.

There is nothing else produced unless you tell how to make it more verbose to provide you what you expect to see. How else you want this to be built?

Thanks.

Andriy Kornatskyy
Post by Stefan Behnel
Post by Andriy Kornatskyy
https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152
Sorry, where? All I see is the command and then the linker command, no
Cython build call, no C compiler build call, no distutils output.
Stefan
_______________________________________________
cython-devel mailing list
https://mail.python.org/mailman/listinfo/cython-devel
Stefan Behnel
2014-08-28 17:13:02 UTC
Permalink
Post by Lisandro Dalcin
Post by Andriy Kornatskyy
When installing either from pip3 or downloading the source with python3 setup.py install
Could you please show us the full output of "python3 setup.py build" ?
It's here:

http://pastebin.com/vZb2gAvL

The other modules build fine, only the package script fails to link. The
problem is the "/EXPORT:PyInit___init__" flag, whereas the real name of the
module init function is (or should be) "PyInit_template", which is the name
of the package.

Does anyone have a good idea how to fix this? Looks like a distutils issue.
I don't think package compilation was originally envisioned as something
extension module authors would want to do.

Does the "cythonize_script_package" test work on MSWindows? It does the
same thing.

Stefan

Loading...