ipyc
ipyc

Reputation: 11

Try to use Cython but linker exits with errors

setup.py:

from setuptools import setup
from Cython.Build import cythonize
setup(ext_modules=cythonize('picmanager.pyx', language_level=311))

Output:

(venv) D:\pythonProject2> python setup.py build
running build
running build_ext......
  Creating library build\temp.win-amd64-cpython-311\Release\picmanager.cp311-win_amd64.lib and object build\temp.win-amd64-cpython-311\Release\picmanager.cp311-win_amd64.exp
MSVCRT.lib(dll_dllmain.obj) : error LNK2001: external symbols that cannot be resolved _initterm......(Omit the remaining 28)
build\lib.win-amd64-cpython-311\picmanager.cp311-win_amd64.pyd : fatal error LNK1120: 29 external commands that cannot be parsed
error: command 'D:\Program Files (x86)\BuildTools\VC\Tools\MSVC\14.37.32822\bin\HostX86\x64\link.exe' failed with exit code 1120

However, initterm.cpp is already at C:\Program Files (x86)\Windows Kits\10\Source\10.0.22621.0\ucrt\startup.

I tried to modify environment variables like INCLUDE, LIB, PATH and TMP but it didn't help.

How to fix this?

I want the program runs normally and the corresponding module can be imported at last

Now that I've made new progress, I've added the environment variable

CRT=D:\Program Files (x86)\BuildTools\VC\Tools\MSVC\14.37.32822\crt\src\vcruntime;
C:\Program Files (x86)\Windows Kits\10\Source\10.0.22621.0\ucrt\startup;

Now the terminal becomes

MSVCRT.lib(utility.obj) : error LNK2001: external symbol _configure_narrow_argv that cannot be resolved
MSVCRT.lib(utility.obj) : error LNK2001: external symbol _initialize_narrow_environment that cannot be resolved
build\lib.win-amd64-cpython-311\picmanager.cp311-win_amd64.pyd : fatal error LNK1120:  2 external commands that can't be resolved

that's good but _configure_narrow_argv is a file name that can't be found

So now I just need to find this file.

I find it in C:\Program Files (x86)\Windows Kits\10\Source\10.0.22621.0\ucrt\startup\argv_parsing.cpp

extern "C" errno_t __cdecl _configure_narrow_argv(_crt_argv_mode const mode)
{
    return common_configure_argv<char>(mode);
}

But why does it report an error

After thinking about it, I think the version may not be compatible? Do you have any suggestions?

I deleted argv_parsing.cpp, but the problem persisted. It didn't seem to be the problem with this file

This problem has been explored by myself to solve it, and I will sort it out later

Upvotes: 1

Views: 96

Answers (0)

Related Questions