Wenn ich meinen Code von setup.py kompiliere, kann er die Include-Datei <array>
von C++ 11 nicht finden - aber C++ 11 Compiler-Funktionen funktionieren.Cython Build kann C++ 11 STL-Dateien nicht finden - aber nur beim Aufruf von setup.py
Wenn ich die gleiche Befehlszeile einfügen, erzeugt in meine Schal setup.py, alles kompiliert sehr gut (!)
-Code dieses Verhalten demonstriert here zu sehen und wird im Folgenden auch eingefügt.
Terminalsitzung:
$ python setup.py build_ext
running build_ext
building 'simple' extension
creating build
creating build/temp.macosx-10.6-intel-3.4
/usr/bin/clang -fno-strict-aliasing -Werror=declaration-after-statement -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -Isrc -I/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m -c simple.cpp -o build/temp.macosx-10.6-intel-3.4/simple.o -Wno-unused-function -std=c++11
In file included from simple.cpp:289:
./simple.h:2:10: fatal error: 'array' file not found
#include <array>
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
$ /usr/bin/clang -fno-strict-aliasing -Werror=declaration-after-statement -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -Isrc -I/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m -c simple.cpp -o build/temp.macosx-10.6-intel-3.4/simple.o -Wno-unused-function -std=c++11
# no error!
$ /usr/bin/clang --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
setup.py:
#!/usr/bin/env python3
import platform, distutils.core, distutils.extension, Cython.Build
EXTENSION = distutils.extension.Extension(
name='simple',
sources=['simple.pyx'],
extra_compile_args=['-Wno-unused-function', '-std=c++11'],
language='c++',
)
EXT_MODULES=Cython.Build.cythonize(
[EXTENSION],
language='c++',
)
distutils.core.setup(
name='simple',
ext_modules=EXT_MODULES,
)
simple.pyx:
cdef extern from "simple.h" namespace "fcolor4":
struct Simple:
int x
simple.h:
int foo() {
auto x = 1; // works, so must be C++11
return x;
}
#include <string> // works, so must find some STL.
#include <array> // fails!
Das hat es! Ich habe mein Demo-Repo geändert, um die richtige Antwort zu geben. Vielen Dank! –
Oh, und 10.9 ist definitiv die kleinste Version, die funktioniert - ich habe 10.7 und 10.8 versucht. –