无法在 M1 上安装 ruby​​ 3.1.0 - 找不到 -lcapstone 的库

Man*_*iah 4 ruby apple-m1

链接共享库 libruby.3.1.dylib ld:找不到 -lcapstone clang 的库:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) make:*** [libruby.3.1.dylib] 错误 1

Man*_*iah 5

如Failed to install ruby​​ 3.1.0 on M1 \xc2\xb7 Discussion #1933 \xc2\xb7 rbenv/ruby-build中所述,有两种方法:

\n
    \n
  1. 指示环境在哪里查找未找到的库:
  2. \n
\n
# Assuming Fish-shell, and that the two following directories are indeed present\n# Adapting to Bourne affine shells is left as an exercise \nset -gx LDFLAGS "-L/opt/homebrew/opt/capstone/lib"\nset -gx CPPFLAGS "-I/opt/homebrew/opt/capstone/include"\n\n# relaunch the install process with installation manager\n# rbenv install 3.1.0\n# asdf install ruby 3.1.0\n
Run Code Online (Sandbox Code Playgroud)\n
    \n
  1. 删除可选依赖项,顶点“在 YJIT 中使用,但仅在cppflags="-DRUBY_DEBUG"指定时使用”:
  2. \n
\n
brew uninstall bloaty\nbrew uninstall capstone\n\n# Adapt to fit local environment:\nset -gx RUBY_CFLAGS "-w"\nrbenv install 3.1.0\n# asdf install ruby 3.1.0\n
Run Code Online (Sandbox Code Playgroud)\n

并通过提供以下内容再次运行安装:

\n

  • 一种独立于 shell 的方法: `env LDFLAGS="-L/opt/homebrew/opt/capstone/lib" CPPFLAGS="-I/opt/homebrew/opt/capstone/include" rbenv install ruby​​ 3.1.0` 。您可能还想使用“brew --prefix capstone”来查找 Homebrew 安装的正确路径。 (3认同)