运行python3 setup.py build_ext
后,将在整个构建过程中生成以下命令:
arm-poky-linux-gnueabi-g++ ... \
-L=/opt/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/ \
-L=/opt/cortexa9hf-neon-poky-linux-gnueabi/lib/ \
-lpython3.5m \
-o build/lib.linux-x86_64-3.5/kiwisolver.cpython-35m-x86_64-linux-gnu.so
会产生以下错误:
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find crti.o: No such file or directory
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find crtbeginS.o: No such file or directory
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find -lpython3.5m
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find -lstdc++
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find -lm
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find -lgcc_s
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find -lc
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find -lgcc_s
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find crtendS.o: No such file or directory
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find crtn.o: No such file or directory
但是,当我将-L=
替换为-L
时,错误减少到了:
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find crti.o: No such file or directory
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find crtbeginS.o: No such file or directory
/opt/x86_64-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.4.0/real-ld: cannot find -lgcc
为什么setuptools使用-L=/path/
而不是-L/path/
为库目录生成标志?
这是我的setup.py
:
from setuptools import setup, Extension
ext_modules = [
Extension(
'kiwisolver',
['py/kiwisolver.cpp',
'py/constraint.cpp',
'py/expression.cpp',
'py/solver.cpp',
'py/strength.cpp',
'py/term.cpp',
'py/variable.cpp'],
include_dirs=[
'.',
'/opt/cortexa9hf-neon-poky-linux-gnueabi/usr/include/python3.5m/'
],
library_dirs=[
'/opt/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/',
'/opt/cortexa9hf-neon-poky-linux-gnueabi/lib/'
],
language='c++',
extra_compiler_args=[
"--verbose"
]
),
]
setup(
name='kiwisolver',
install_requires=['setuptools'],
ext_modules=ext_modules,
)