【RUST】mac m1编译rust项目失败: could not compile `` due to previous error

这篇具有很好参考价值的文章主要介绍了【RUST】mac m1编译rust项目失败: could not compile `` due to previous error。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1. 问题描述

执行cargo命令:

  RUST_LOG=info cargo run --example demo --quiet

错误如下:

error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="......."
  = note: ld: in /.../my_project/target/debug/deps/libcrypto-d7fa53ad481a6fe9.rlib(util_helpers.o), archive member 'util_helpers.o' with length 3560 is not mach-o or llvm bitcode file '/.../my_project/target/debug/deps/libcrypto-d7fa53ad481a6fe9.rlib' for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          
error: could not compile `my_project` due to previous error	

2. 解决办法:

查看llvm-ar安装路径(没有则需要安装):

2.1 查看clang:

which clang

结果如下:

/usr/local/opt/llvm/bin/clang

2.2 查看llvm-ar:

which llvm-ar

结果如下:

/usr/local/opt/llvm/bin/llvm-ar

2.3 如果没有安装llvm-ar,安装命令如下:

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
arch -x86_64 /usr/local/bin/brew install llvm
export PATH="/usr/local/opt/llvm/bin:$PATH"

2.4 查看是否安装成功命令:

/usr/local/opt/llvm/bin/llvm-ar --version

结果如下:

Homebrew LLVM version 16.0.1
  Optimized build.

2.5 重新执行cargo 命令:
执行cargo clean:

sudo cargo clean

执行一次带AR参数的cargo命令(本人执行一次就好了):

AR=/usr/local/opt/llvm/bin/llvm-ar  CC=/usr/local/opt/llvm/bin/clang  RUST_LOG=info cargo run --example demo --quiet

如果没有没有报错, 后续就可以使用正常的cargo命令去跑代码了

如果没有生效, 可以尝试删除掉target之后再试试

#参考文档: https://github.com/rust-bitcoin/rust-secp256k1/issues/283文章来源地址https://www.toymoban.com/news/detail-724748.html

到了这里,关于【RUST】mac m1编译rust项目失败: could not compile `` due to previous error的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • XML-BEANS compiled schema: Could not locate compiled schema resource 异常处理

    使用poi5.2.2生成ppt,生成堆叠图,设置值时抛出异常 XML-BEANS compiled schema: Could not locate compiled schema resource org/apache/poi/schemas/ooxml/system/ooxml/stoverlappercent872etype.xsb (org.apache.poi.schemas.ooxml.system.ooxml.stoverlappercent872etype) - code 0 异常显示缺少stoverlappercent872etype.xsb文件,检查poi-ooxml包和

    2024年02月13日
    浏览(27)
  • Rust rust-crypto 编译报错

    问题描述: Cargo.toml中引入【rust-crypto = “0.2”】,执行【cargo build】编译项目报错,在rust-crypto时遇到cc是否安装的错误,控制台还有github的解决方案,是在toml中加入 并未解决问题! 问题解决: 猜测Linux下gcc和cc,好像是很类似的东西。 因为是Windows下安装的mingw,看了mingw的

    2024年02月12日
    浏览(29)
  • 解决PyCharm安装其他库包时出现的“error: can‘t find Rust compiler“错误

    解决PyCharm安装其他库包时出现的\\\"error: can’t find Rust compiler\\\"错误 在使用PyCharm安装其他Python库包时,有时候会遇到\\\"error: can’t find Rust compiler\\\"的错误提示。这个错误通常是由于缺少Rust编译器导致的。Rust是一种系统级编程语言,一些Python库包在安装过程中需要使用Rust编译器来编

    2024年03月23日
    浏览(49)
  • 【Rust日报】用Rust从头实现一个C编译器

    一个声明式解析库 Untwine 发布0.4 Untwine是一个声明性解析库,它允许一种类似于使用自定义宏语法进行直接模式匹配的解析风格。这允许创建具有良好性能特征和高质量错误消息的极其紧凑的解析器。这些解析器实现起来很简单,有几个精心挑选的例子: 一个几乎完整的JSO

    2024年04月22日
    浏览(27)
  • 提速Rust编译器!

    Nethercote是一位研究Rust编译器的软件工程师。最近,他正在探索如何提升Rust编译器的性能,在他的博客文章中介绍了Rust编译器是如何将代码分割成代码生成单元(CGU)的以及rustc的性能加速。 他解释了不同数量和大小的CGU之间的权衡以及Rustc是如何使用LLVM并行化代码生成和优

    2024年02月13日
    浏览(25)
  • Rust源码编译

    Rust程序源代码文件后缀名为 .rs 程序文件命名规范为小写字母加下划线,比如 hello_world.rs rustc hello.rs 执行后在当前目录生成hello可执行程序 cargo 是Rust的构建系统和包管理工具,能够构建项目代码、下载依赖库、构建库,在安装Rust时会自动安装 cargo , 判断 cargo 是否正确安装的

    2024年02月11日
    浏览(17)
  • mac M1安转node-canvas失败

    Failed to execute \\\'/Users/.nvm/versions/node/v14.20.0/bin/node /Users/.nvm/versions/node/v14.20.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/Users/qsk/Projects/arms-inspections/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/Projects/arms-inspectio

    2024年02月11日
    浏览(33)
  • Rust交叉编译简述 —— Arm

    使用系统:WSL2 —— Kali(Microsoft Store) 命令列表 写入: 使用qemu进行测试:

    2024年02月12日
    浏览(24)
  • RUST Rover 条件编译 异常处理

    会报异常 error: failed to parse manifest at C:UserstopmaRustroverProjectsuntitled2Cargo.toml 网上说明 这样处理 https://course.rs/cargo/reference/features/intro.html RUST 圣经里描述

    2024年04月09日
    浏览(26)
  • Rust 入门-更换镜像源(MAC)

    首先是在 crates.io 之外添加新的注册服务,在 $HOME/.cargo/config.toml (如果文件不存在则手动创建一个)中添加以下内容 首先,创建一个新的镜像源 [source.ustc],然后将默认的 crates-io 替换成新的镜像源: replace-with = ‘ustc’。 简单吧?只要这样配置后,以往需要去 crates.io 下载的

    2024年04月17日
    浏览(16)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包