代码之家  ›  专栏  ›  技术社区  ›  Sbmueller

crystal命令失败,ld:找不到-lgc的库

  •  1
  • Sbmueller  · 技术社区  · 7 年前

    尝试运行程序时 hello 从…起 https://github.com/askn/crystal-by-example ,我得到以下输出

    $ crystal hello.cr
    ld: library not found for -lgc
    clang: error: linker command failed with exit code 1 (use -v to see . invocation)
    Error: execution of command failed with code: 1: `cc "${@}" -o '/Users/senpo/.cache/crystal/crystal-run-hello.tmp'  -rdynamic  -lpcre -lgc -lpthread /opt/brew/Cellar/crystal-lang/0.24.1_1/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/lib -L/usr/local/lib`
    

    我已经试过了

    1. xcode-select --install
    2. xcode-select --switch /Library/Developer/CommandLineTools
    3. 重新安装XCode

    但仍然会得到相同的错误。谁能帮我把水晶安装好吗?

    2 回复  |  直到 7 年前
        1
  •  2
  •   Sbmueller    7 年前

    我在 https://github.com/crystal-lang/crystal/issues/3067 . 这似乎是一个已知的晶体问题。解决方案是设置环境变量 LIBRARY_PATH 在我的情况下,请访问homebrew安装的库文件夹 /opt/brew/lib :

    export LIBRARY_PATH=/opt/brew/lib
    
        2
  •  1
  •   Oleh Sobchuk    7 年前

    使用运行它 run 命令

    crystal run hello.cr
    

    或者您可以构建包并运行构建的代码

    crystal build hello.cr
    ./hello