mac編譯rust程序返回錯誤error: linking with `cc` failed: exit status: 1

字號+ 編輯: 种花家 修訂: 种花家 來源: 原创 2024-08-27 我要說兩句(1)

之前因爲動了mac的conda環境,在編譯rust程序時居然出了問題,本文記錄報錯的文本以及解決方案。

在开始编译时,控制台返回:

error: linking with `cc` failed: exit status: 1
中间文本是海量的报错
= note: ld: library 'System' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

网上有一大堆解决方法,比如重装rustrover, 重新安装commandline-tools, 没一个有用

解决记录

发现报错文字里有大量的Python字样,随手删了homebrew安装的python 3.12,安装commandline-tools

brew cleanup
brew uninstall python --ignore-dependencies

如果你动过commandline-tools,得删了重装一下

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --reset    
sudo rm -rf ~/Library/Developer/Xcode
xcode-select --install

重要的步骤是,我的mac用户下的.zshrc(路径是~/.zshrc)这个文件被定制过,把里面的内容清理了一下。

解决收工

閲完此文,您的感想如何?
  • 有用

    3

  • 沒用

    1

  • 開心

    1

  • 憤怒

    1

  • 可憐

    1

1.如文章侵犯了您的版權,請發郵件通知本站,該文章將在24小時内刪除;
2.本站標注原創的文章,轉發時煩請注明來源;
3.交流群: 2702237 13835667

相關課文
  • 在rust/axum框架中操作redis

  • rust編譯新的wasm項目操作流程(原文: 編譯 Rust 爲 WebAssembly)

  • rust視圖模板庫askama的使用

  • axum框架當中獲取請求header, 和獲取header指定字段的方法

我要說說
網上賓友點評
1 樓 IP 222.128.***.254 的嘉賓 说道 : 半年前
我也用的RustRover,楼主方法好用