美文网首页Rust语言Rust语言和应用Rust
Mac上Cargo编译错误: failed to run cus

Mac上Cargo编译错误: failed to run cus

作者: 姜家志 | 来源:发表于2019-01-12 22:47 被阅读4次

    编译Rust的项目时候出现了错误:

    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"
    

    关键的错误信息是:

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

    原因是升级了Mac系统之后 C++ .h 不正确造成的。
    解决的方式,是删除clang相关的编译环境,并重新安装,首先删除头文件:

    rm -rf /usr/local/include/*

    再卸载LLVM相关的工具链

    brew uninstall llvm

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

    rm -rf /Library/Developer/CommandLineTools

    卸载掉clang相关工具之后,再重新安装。
    安装Xcode命令行工具:

    xcode-select --install

    安装llvm

    brew install --with-toolchain llvm

    重新编译正常。

    相关文章

      网友评论

        本文标题:Mac上Cargo编译错误: failed to run cus

        本文链接:https://www.haomeiwen.com/subject/ffbcdqtx.html