代码之家  ›  专栏  ›  技术社区  ›  Li-yao Xia

如何在Windows上获取ar

  •  0
  • Li-yao Xia  · 技术社区  · 4 年前

    我正在尝试在windows上使用cabal(使用Chocolate安装),它正在寻找“ar”,这是一个GNU实用程序,我不知道如何安装它。

    # In powershell or git bash
    git clone https://github.com/haskell/text
    cd text
    cabal build --with-gcc=msys2
    

    错误信息摘录(是的,我有意使用8.2.2, -w ghc-8.2.2 ):

    Failed to build call-stack-0.4.0.
    Build log (
    C:\cabal\logs\ghc-8.2.2\call-stack-0.4.0-99b0801375eba6b85bc1a82c10630c85f20debfa.log
    ):
    Preprocessing library for call-stack-0.4.0..
    Building library for call-stack-0.4.0..
    [1 of 3] Compiling Data.SrcLoc      ( src\Data\SrcLoc.hs, dist\build\Data\SrcLoc.o )
    [2 of 3] Compiling Data.CallStack   ( src\Data\CallStack.hs, dist\build\Data\CallStack.o )
    [3 of 3] Compiling Paths_call_stack ( dist\build\autogen\Paths_call_stack.hs, dist\build\Paths_call_stack.o )
    cabal.exe: The program 'ar' is required but it could not be found.
    
    
    
    (and a whole lot more identical errors for other packages)
    
    0 回复  |  直到 4 年前
        1
  •  2
  •   duplode    4 年前

    您可能需要安装GCC,就我在机器上查看MSYS2的设置所知,它似乎不是最初安装MSYS2时附带的。这将通过MSYS外壳上的pacman完成(参见 the MSYS2 wiki 对于MSYS2外壳和子系统的底漆):

    # Updates the package database and the currently installed packages.
    # If the shell closes at the end of the update, reopen it and rerun.
    pacman -Syu
    # Installs gcc.
    pacman -S mingw-w64-x86_64-gcc
    

    特别地, ar 作为的一部分安装 mingw-w64-x86_64-binutils ,这是 mingw-w64-x86_64-gcc .

    补充说明:

    • GCC将安装到 mingw64\bin 在你的MSYS2根下。您可能希望将该位置添加到路径中。

    • As you found out ,如果你是通过巧克力来管理工具, choco install mingw 将建立基本的MinGW开发工具链,其中包括GCC。

    推荐文章