安装用 C++ 编写的 Python 包 (leven) 时出错:g++ 无法识别的命令行选项 --output-lib
Error installing Python package (leven) written in C++: g++ unrecognized command line option --output-lib
我一整天都在尝试安装这个 Python 库。它叫做 leven,您可以在这里找到它:https://pypi.python.org/pypi/leven/.
它是用 C++ 编写的,我在尝试构建和安装它时遇到错误。要从命令行构建和安装我 运行:python setup.py 安装。它 运行 是它的一部分,直到它在 运行 执行命令
时失败
C:\Program Files (x86)\CodeBlocks\MinGW\bin\g++.exe -mdll -static --entry _DllMain@12 --output-lib build\temp.win32-2.7\Release\leven\lib_levenshtein.a --def build\temp.win32-2.7\Release\leven\_levenshtein.def -s build\temp.win32-2.7\Release\leven\_levenshtein.o -LC:\Python27\libs -LC:\Python27\PCbuild -lpython27 -lmsvcr90 -o build\lib.win32-2.7\leven\_levenshtein.pyd
g++: error: unrecognized command line option '--output-lib'
g++: error: build\temp.win32-2.7\Release\leven\lib_levenshtein.a: No such file or directory
error: command 'C:\Program Files (x86)\CodeBlocks\MinGW\bin\g++.exe' failed with exit status 1
而整个事情,当我 运行 python setup.py 安装时是:
C:\Python27\Lib\site-packages>python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to leven.egg-info\requires.txt
writing leven.egg-info\PKG-INFO
writing top-level names to leven.egg-info\top_level.txt
writing dependency_links to leven.egg-info\dependency_links.txt
reading manifest file 'leven.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'leven.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
running build_ext
building 'leven._levenshtein' extension
C:\Program Files (x86)\CodeBlocks\MinGW\bin\gcc.exe -mdll -O -Wall -Ileven -IC:\Python27\include -IC:\Python27\PC -c leven/_levenshtein.cpp -o build\temp.win32-2.7\Release\leven\_levenshtein.o
leven/_levenshtein.cpp: In function 'void __Pyx_RaiseArgtupleInvalid(const char*, int, Py_ssize_t, Py_ssize_t, Py_ssize_t)':
leven/_levenshtein.cpp:1400:59: warning: unknown conversion type character 'z' in format [-Wformat]
leven/_levenshtein.cpp:1400:59: warning: format '%s' expects argument of type 'char*', but argument 5 has type 'Py_ssize_t {aka int}' [-Wformat]
leven/_levenshtein.cpp:1400:59: warning: unknown conversion type character 'z' in format [-Wformat]
leven/_levenshtein.cpp:1400:59: warning: too many arguments for format [-Wformat-extra-args]
writing build\temp.win32-2.7\Release\leven\_levenshtein.def
C:\Program Files (x86)\CodeBlocks\MinGW\bin\g++.exe -mdll -static --entry _DllMain@12 --output-lib build\temp.win32-2.7\Release\leven\lib_levenshtein.a --def build\temp.win32-2.7\Release\leven\_levenshtein.def -s build\temp.win32-2.7\Release\leven\_levenshtein.o -LC:\Python27\libs -LC:\Python27\PCbuild -lpython27 -lmsvcr90 -o build\lib.win32-2.7\leven\_levenshtein.pyd
g++: error: unrecognized command line option '--output-lib'
g++: error: build\temp.win32-2.7\Release\leven\lib_levenshtein.a: No such file or directory
error: command 'C:\Program Files (x86)\CodeBlocks\MinGW\bin\g++.exe' failed with exit status 1
这个问题的答案是用“-out-implib=name”替换“--output-lib name”。
我 运行 现在遇到了另一个问题。我需要在 cygwinccompiler.py 中将 --output-lib 更改为 -implib=name,以便它在我调用 python setup.py install 时运行那个包,但我一直在 implib= 和名称之间得到一个额外的空格,我认为这是程序停止工作的原因。对这个问题有什么想法吗?
我一整天都在尝试安装这个 Python 库。它叫做 leven,您可以在这里找到它:https://pypi.python.org/pypi/leven/.
它是用 C++ 编写的,我在尝试构建和安装它时遇到错误。要从命令行构建和安装我 运行:python setup.py 安装。它 运行 是它的一部分,直到它在 运行 执行命令
时失败C:\Program Files (x86)\CodeBlocks\MinGW\bin\g++.exe -mdll -static --entry _DllMain@12 --output-lib build\temp.win32-2.7\Release\leven\lib_levenshtein.a --def build\temp.win32-2.7\Release\leven\_levenshtein.def -s build\temp.win32-2.7\Release\leven\_levenshtein.o -LC:\Python27\libs -LC:\Python27\PCbuild -lpython27 -lmsvcr90 -o build\lib.win32-2.7\leven\_levenshtein.pyd
g++: error: unrecognized command line option '--output-lib'
g++: error: build\temp.win32-2.7\Release\leven\lib_levenshtein.a: No such file or directory
error: command 'C:\Program Files (x86)\CodeBlocks\MinGW\bin\g++.exe' failed with exit status 1
而整个事情,当我 运行 python setup.py 安装时是:
C:\Python27\Lib\site-packages>python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to leven.egg-info\requires.txt
writing leven.egg-info\PKG-INFO
writing top-level names to leven.egg-info\top_level.txt
writing dependency_links to leven.egg-info\dependency_links.txt
reading manifest file 'leven.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'leven.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
running build_ext
building 'leven._levenshtein' extension
C:\Program Files (x86)\CodeBlocks\MinGW\bin\gcc.exe -mdll -O -Wall -Ileven -IC:\Python27\include -IC:\Python27\PC -c leven/_levenshtein.cpp -o build\temp.win32-2.7\Release\leven\_levenshtein.o
leven/_levenshtein.cpp: In function 'void __Pyx_RaiseArgtupleInvalid(const char*, int, Py_ssize_t, Py_ssize_t, Py_ssize_t)':
leven/_levenshtein.cpp:1400:59: warning: unknown conversion type character 'z' in format [-Wformat]
leven/_levenshtein.cpp:1400:59: warning: format '%s' expects argument of type 'char*', but argument 5 has type 'Py_ssize_t {aka int}' [-Wformat]
leven/_levenshtein.cpp:1400:59: warning: unknown conversion type character 'z' in format [-Wformat]
leven/_levenshtein.cpp:1400:59: warning: too many arguments for format [-Wformat-extra-args]
writing build\temp.win32-2.7\Release\leven\_levenshtein.def
C:\Program Files (x86)\CodeBlocks\MinGW\bin\g++.exe -mdll -static --entry _DllMain@12 --output-lib build\temp.win32-2.7\Release\leven\lib_levenshtein.a --def build\temp.win32-2.7\Release\leven\_levenshtein.def -s build\temp.win32-2.7\Release\leven\_levenshtein.o -LC:\Python27\libs -LC:\Python27\PCbuild -lpython27 -lmsvcr90 -o build\lib.win32-2.7\leven\_levenshtein.pyd
g++: error: unrecognized command line option '--output-lib'
g++: error: build\temp.win32-2.7\Release\leven\lib_levenshtein.a: No such file or directory
error: command 'C:\Program Files (x86)\CodeBlocks\MinGW\bin\g++.exe' failed with exit status 1
这个问题的答案是用“-out-implib=name”替换“--output-lib name”。
我 运行 现在遇到了另一个问题。我需要在 cygwinccompiler.py 中将 --output-lib 更改为 -implib=name,以便它在我调用 python setup.py install 时运行那个包,但我一直在 implib= 和名称之间得到一个额外的空格,我认为这是程序停止工作的原因。对这个问题有什么想法吗?