更新时间:2022-12-22 22:00:12
当前MacOS安装的问题。您可以调整 setup.py
,并按照警告提示将 -std = libc ++
添加到编译选项中,即
This is a special issue with current MacOS-installations. You could tweak setup.py
and add, as the warning suggest, -std=libc++
to the compile-options, i.e.
from distutils.core import setup
from Cython.Build import cythonize
... some stuff
#passing `-stdlib=libc++` to compiler and linker:
ext_modules = [Extension(...,
language='c++',
extra_compile_args=["-stdlib=libc++"], # + anything else you need
extra_link_args= ["-stdlib=libc++"] # + anything else you need]
... some more stuff
我还添加了 -stdlib = libc ++
到链接器选项,因为这可能是您将遇到的下一个问题。
I have also added -stdlib=libc++
to the linker options, because it will be probably the next problem you will run into.
更多背景:在MacOS世界中,长期存在其中c ++标准库的两种不同实现: -libstdc ++
与 gcc
和 libc ++ 相关联code >与
clang
关联。开始时, -libstdc ++
也默认使用 clang
-compiler。但是,情况不再如此-甚至现在都没有安装,这就是找不到标头的原因。我不确定为什么您的 clang
版本不会默认使用 libc ++
-因此您必须通过它手动添加到编译器/链接器。
More background: In the MacOS world, for long time, there where two different implementations of c++'s standard library: -libstdc++
associated with gcc
and libc++
associated with clang
. At the beginning-libstdc++
was also used per default with clang
-compiler. However, this is no longer the case - it is not even installed now and that is the reason why the headers cannot be found. I'm not sure why your clang
-version doesn't take libc++
per default - so you have to pass it manually to compiler/linker.