在目录 ['lib']...LINK 中找不到库 'radial':致命错误 LNK1181:无法打开输入文件 'radial.lib'

could not find library 'radial' in directories ['lib']...LINK : fatal error LNK1181: cannot open input file 'radial.lib'

我在 Python 3.7Fortran FOR 中混合了一些代码。当我在 Intel CMD 运行 python setup.py install 中使用 Visual Studio 2019 和 Intel Parallel Studio 2019 integrated.so 我收到此错误:

could not find library 'radial' in directories ['lib']...
LINK : fatal error LNK1181: cannot open input file 'radial.lib'
error: Command "C:\Program Files (x86)\Microsoft Visual Studio19\Enterprise\VC\Tools\MSVC.21.27702\bin\HostX86\x64\link.exe...
… failed with exit status 1181

如有任何帮助,我们将不胜感激。

setup.py:

#! /usr/bin/env python
# Last Change: Sun Dec 19 11:00 AM 2010 J

# Copyright (C) 2008 Alexander Vinokurov <alexander.a.vinokurov@gmail.com>

descr   = """ScattPy package.

ScattPy provides numerical methods for solving light scattering problem
by non-spherical particles.
"""

import os
import sys

DISTNAME            = 'scikits.scattpy'
DESCRIPTION         = 'Light Scattering methods for Python'
LONG_DESCRIPTION    = descr
MAINTAINER          = 'Alexander Vinokurov'
MAINTAINER_EMAIL    = 'scattpy@googlegroups.com'
URL                 = 'http://scattpy.github.com'
LICENSE             = 'BSD'
VERSION             = '0.1.2'
DOWNLOAD_URL        = 'http://github.com/downloads/ScattPy/scikits.scattpy/scikits.scattpy-'+VERSION+'.tar.gz'

import setuptools
from numpy.distutils.core import setup

def configuration(parent_package='', top_path=None, package_name=DISTNAME):
    if os.path.exists('MANIFEST'): os.remove('MANIFEST')

    from numpy.distutils.misc_util import Configuration
    config = Configuration(package_name, parent_package, top_path,
                           version = VERSION,
                           maintainer  = MAINTAINER,
                           maintainer_email = MAINTAINER_EMAIL,
                           description = DESCRIPTION,
                           license = LICENSE,
                           url = URL,
                           download_url = DOWNLOAD_URL,
                           long_description = LONG_DESCRIPTION)

    config.set_options(
        ignore_setup_xxx_py = True,
        assume_default_configuration = True,
        delegate_options_to_subpackages = True,
        quiet = True,
        )

#    config.add_subpackage("scikits")
#    config.add_data_files("scikits/__init__.py")

#    config.add_extension('f_utils',
#                         sources=[os.path.join('src', 'f_utils.for')]
#                         )

    config.add_extension('f_utils',
                         sources=[os.path.join('src', 'f_utils.for')]
                         )
    config.add_extension('f_spheroid',
                         sources=[os.path.join('src', 'sdmn.f')]
                         )

    config.add_extension('f_radial',
        sources=[os.path.join('src', 'radial.for')],
        library_dirs=["lib"],
        libraries=["radial"]
    )

    return config

if __name__ == "__main__":
    setup(configuration = configuration,
        install_requires = 'numpy',
        namespace_packages = ['scikits'],
        packages = setuptools.find_packages(),
        include_package_data = True,
        #test_suite="tester", # for python setup.py test
        zip_safe = True, # the package can run out of an .egg file
        classifiers =
            [ 'Development Status :: 4 - Beta',
              'Environment :: Console',
              'Intended Audience :: Developers',
              'Intended Audience :: Science/Research',
              'Intended Audience :: Education',
              'License :: OSI Approved :: BSD License',
              'Topic :: Scientific/Engineering :: Mathematics',
              'Topic :: Scientific/Engineering :: Physics',
              'Topic :: Scientific/Engineering :: Astronomy', ])

更新#2:

我的Intel CMD一段代码:

有一些命令可能会导致它工作错误,但现在我不知道:

python setup.py install

    ...

compiling Fortran sources
Fortran f77 compiler: C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\bin\intel64\ifort.exe Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\bin\intel64\ifort.exe /nologo /MD /nbs /names:lowercase /assume:underscore /O1
Fortran f90 compiler: C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\bin\intel64\ifort.exe Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\bin\intel64\ifort.exe /nologo /MD /nbs /names:lowercase /assume:underscore /O1
Fortran fix compiler: C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\bin\intel64\ifort.exe Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\bin\intel64\ifort.exe /nologo /MD /nbs /names:lowercase /assume:underscore /O1
compile options: '-Ibuild\src.win-amd64-3.7\build\src.win-amd64-3.7\scikits\scattpy -IC:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\core\include -IC:\Users\admin\AppData\Local\Programs\Python\Python37\include -IC:\Users\admin\AppData\Local\Programs\Python\Python37\include -c'
ifort.exe:f77: build\src.win-amd64-3.7\scikits\scattpy\f_radial-f2pywrappers.f
ifort.exe:f77: src\radial.for
ifort: command line warininfg #ort: co10161: unrecognized source type 'Files'; object file assumed
mmand line warning #ifort: command line warning #10161: unrecognized source type '(x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\bin\intel64\ifort.exe'; object file assumed
10161: unifort: command line warning #10006: ignoring unknown option '/c '
recognized source type 'Files'; object file assumed
ifort: command line warning #10161: unrecognized source type '(x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\bin\intel64\ifort.exe'; object file assumed
ifort: command line warning #10006: ignoring unknown option '/c '
ifort: warning #10145: no action performed for file 'Files'
ifort: warning #10145: no action performed for file '(x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\bin\intel64\ifort.exe'
ifort: warning #10145: no action performed for file 'Files'
ifort: warning #10145: no action performed for file '(x86)\IntelSWTools\compilers_and_libraries_2019.4.228\windows\bin\intel64\ifort.exe'
could not find library 'radial' in directories ['lib']
...
LINK : fatal error LNK1181: cannot open input file 'radial.lib'
...
failed with exit status 1181

更新#1:

我看到My Intel CMDSetup.py之间存在如下逻辑对应关系,所以也许调整PATH可以解决问题:

My Intel CMD 一段代码:

#1 ifort.exe:f77: src\radial.for

#2 could not find library 'radial' in directories ['lib']

setup.py:

#1 sources=[os.path.join('src', 'radial.for')],

#2 library_dirs=["lib"], libraries=["radial"]

更新#2:

因为我使用 MINGW gfortran 而不是 Intel Parallel Studio 2019 并使用 Microsoft Visual Studio Build Tools 2019 而不是 Microsoft Vissual Studio 2019 并使用 latest version of Python ,请勿修改 setup.py并在 中对 UPADTE #1 和 UPDATE #2 进行一些更改,我的问题已解决。

您没有显示实际执行的 ifort 命令。您标记为 "my Intel CMD" 的输出(实际上不是)表示 ifort 命令行上的路径包含 space Program Files (x86) 但未正确引用。这阻止了您的源代码被编译。在我看来,好像 python 脚本出错了。奇怪的是,它在调用编译器的同时也在命令行中放置了编译器的路径,就好像它是一个源文件一样。

您将需要深入研究(此处未显示)脚本并确定它构建错误命令行的原因。

因为我使用 MINGW gfortran 代替 Intel Parallel Studio 2019 并使用 Microsoft Visual Studio Build Tools 2019 代替 Microsoft Vissual Studio 2019 并使用 latest version of Python ,请勿修改 setup.py并在 中对 UPADTE #1 和 UPDATE #2 进行一些更改,我的问题已解决。