📚
M1 Macでpip install flaskしたらgreenletのコンパイルでエラーになった
xcode-utilは入っている前提です。
pip install flaskをM1 Macで実行した際、greenletのコンパイルで「stdio.h not found」とか
clang -bundle -undefined dynamic_lookup -arch arm64 -arch x86_64 -Wl,-headerpad,0x1000 build/temp.macosx-10.14.6-arm64-3.8/src/greenlet/greenlet.o -o build/lib.macosx-10.14.6-arm64-3.8/greenlet/_greenlet.cpython-38-darwin.so
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
みたいな感じで-lSystemが無いというエラーが出てきました。
まずstdio.hに関してですが、https://takemikami.com/2020/12/07/macOS-CatalinaPyMC3fatal-error-stdioh-file-not-found.html を参考にして、
$ export CPATH=`xcrun --show-sdk-path`/usr/include
と加えることで認識されました。
また、-lSystemが無いと言われる件に関しては、
$ export LIBRARY_PATH="$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"
と加えることで回避できました。なんか同じ問題がRustのコンパイルの時もあった気がします。
Discussion