首页 > 解决方案 > 由于缺少库,Github Action 在 Windows 上失败

问题描述

我刚刚发现了 Github 工作流,我一直在尝试为我的私有 C++ 存储库创建两个,其中包含一个小型 C++ 库。

我已经成功地创建了一个在 Ubuntu 上运行(即,它成功运行并完成),但另一个在 Windows 上运行(几乎是在 Ubuntu 上运行的那个完全相同的副本)由于缺少 C 库而失败。

这是.yml在 Windows 上运行的工作流文件:

name: CMake

on:
  push:
    branches: [ master ]
  
  pull_request:
    branches: [ master ]
  
env:  
  # the directory of the library's source code (and which contains the CMakeLists.txt)
  LAL_DIR: D:\a\linear-arrangement-library\linear-arrangement-library/lal
  # directories of the different builds
  REL_DIR: ${{github.workspace}}/windows-build-release
  DEB_DIR: ${{github.workspace}}/windows-build-debug

jobs:
  windows_build:
    runs-on: windows-2019
    
    steps:
    - uses: actions/checkout@v2
    
    - name: Configure CMake on Windows
      run: cmake -G "MSYS Makefiles" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ ${{env.LAL_DIR}} -B ${{env.REL_DIR}} -DCMAKE_BUILD_TYPE=Release ;
           cmake -G "MSYS Makefiles" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ ${{env.LAL_DIR}} -B ${{env.DEB_DIR}} -DCMAKE_BUILD_TYPE=Debug
    
    - name: Build on Windows
      run: cmake --build ${{env.REL_DIR}} --config Release -j4 ;
           cmake --build ${{env.DEB_DIR}} --config Debug -j4

我是新手,所以我不知道我是否应用了“最佳实践”(如果有的话)。

我得到的错误如下:

In file included from D:/a/linear-arrangement-library/linear-arrangement-library/lal/generate/rand_ulab_rooted_trees.hpp:50,
                 from D:/a/linear-arrangement-library/linear-arrangement-library/lal/generate/rand_ulab_free_trees.hpp:50,
                 from D:/a/linear-arrangement-library/linear-arrangement-library/lal/generate/rand_ulab_free_trees.cpp:42:
D:/a/linear-arrangement-library/linear-arrangement-library/lal/numeric/integer.hpp:45:10: fatal error: gmp.h: No such file or directory
 #include <gmp.h>
          ^~~~~~~
compilation terminated.

错误告诉我g++找不到文件gmp.h。但是,在 Ubuntu 上运行的工作流程不会失败。

我猜想执行 Ubuntu 工作流程的系统只是gmp安装了库,而执行 Window 工作流程的系统没有。我该如何解决这个问题?(如果真的有可能,那就是)

非常感谢。

标签: github-actions

解决方案


推荐阅读