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

編譯Rust的項(xiàng)目時(shí)候出現(xiàn)了錯(cuò)誤:

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"

關(guān)鍵的錯(cuò)誤信息是:

error: unknown type name 'uint64_t' cargo:warning= uint64_t ri resident_size;

原因是升級(jí)了Mac系統(tǒng)之后 C++ .h 不正確造成的。
解決的方式,是刪除clang相關(guān)的編譯環(huán)境,并重新安裝,首先刪除頭文件:

rm -rf /usr/local/include/*

再卸載LLVM相關(guān)的工具鏈

brew uninstall llvm

最后需要卸載掉Xcode命令行工具:

rm -rf /Library/Developer/CommandLineTools

卸載掉clang相關(guān)工具之后,再重新安裝。
安裝Xcode命令行工具:

xcode-select --install

安裝llvm

brew install --with-toolchain llvm

重新編譯正常。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容