Mac上Cargo編譯錯誤: failed to run custom build command for '*.*'

編譯Rust的項目時候出現了錯誤:xcode

error: failed to run custom build command for croaring-sys v0.3.7
process didn't exit successfully: /Users/.../grin/target/release/build/croaring-sys-20d6d5c35e3a436a/build-script-build (exit code: 101) --- stdout TARGET = Some("x86_64-apple-darwin") OPT_LEVEL = Some("3") HOST = Some("x86_64-apple-darwin") CC_x86_64-apple-darwin = None CC_x86_64_apple_darwin = None HOST_CC = None CC = None CFLAGS_x86_64-apple-darwin = None CFLAGS_x86_64_apple_darwin = None HOST_CFLAGS = None CFLAGS = None DEBUG = Some("false") running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-Wall" "-Wextra" "-std=c11" "-march=native" "-O3" "-o" "/Users/.../grin/target/release/build/croaring-sys-4f7af44253f571e8/out/CRoaring/roaring.o" "-c" "CRoaring/roaring.c" 複製代碼

關鍵的錯誤信息是:bash

error: unknown type name 'uint64_t' cargo:warning= uint64_t ri resident_size;
複製代碼

緣由是升級了Mac系統以後 C++ .h 不正確形成的。 解決的方式,是刪除clang相關的編譯環境,並從新安裝,首先刪除頭文件:app

rm -rf /usr/local/include/*ide

再卸載LLVM相關的工具鏈工具

brew uninstall llvmui

最後須要卸載掉Xcode命令行工具:spa

rm -rf /Library/Developer/CommandLineTools命令行

卸載掉clang相關工具以後,再從新安裝。 安裝Xcode命令行工具:code

xcode-select --installip

安裝llvm

brew install --with-toolchain llvm

從新編譯正常。

相關文章
相關標籤/搜索