Unable to compile my C Extension on Windows: unresolved external link errors

Marco Sulla Marco.Sulla.Python at gmail.com
Fri Nov 12 09:30:01 EST 2021


I have no problem compiling my extension under Linux and MacOS. Under
Windows, I get a lot of

Error LNK2001: unresolved external symbol PyErr_SetObject

and so on.

I post the part of my setup.py about the C Extension:

extra_compile_args = ["-DPY_SSIZE_T_CLEAN", "-DPy_BUILD_CORE"]
undef_macros = []

setuptools.Extension(
    ext1_fullname,
    sources = cpython_sources,
    include_dirs = cpython_include_dirs,
    extra_compile_args = extra_compile_args,
    undef_macros = undef_macros,
)

Here is the full code:
https://github.com/Marco-Sulla/python-frozendict/blob/master/setup.py

Steps to reproduce: I installed python3.10 and VS compiler on my
Windows 10 machine, then I created a venv, activated it, run

pip install -U pip setuptools wheel

and then

python setup.py bdist_wheel


More information about the Python-list mailing list