0

I've just discovered Github workflows and I've been trying to create two for a private C++ repository of mine, which contains a small C++ library.

I've succeeded in creating one that runs on Ubuntu (i.e., it runs and completes successfully), but the other that runs on Windows (almost an exact copy of that one that runs on Ubuntu) fails due to a missing C library.

This is the .yml file of the workflow that runs on 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

I'm new on this, so I don't know if I applied the "best practices" (if there are any).

The error I get is the following:

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.

The error is telling me that g++ can't find the file gmp.h. The workflow running on Ubuntu, however, does not fail.

I guess that the system executing Ubuntu's workflow simply has the gmp library installed, whereas the one executing Window's workflow doesn't. How can I resolve this? (if it is actually possible, that is)

Thank you very much.

  • According to what I read [here](https://stackoverflow.com/questions/7351205/where-to-find-gmp-h) and [here](https://stackoverflow.com/questions/5172723/compiling-gdc-on-windows-where-to-get-gmp-and-mpfr-dependencies) you may need to install [GMP](http://rstudio-pubs-static.s3.amazonaws.com/493124_a46782f9253a4b8193595b6b2a037d58.html) on the windows runner as it might not be supported on this version. In that case, you would need to do this installation through command lines using another step in your windows workflow job. – GuiFalourd Aug 05 '21 at 12:30
  • Ugh... I read somewhere that sometimes this is needed. E.g., one can install gcc-10 using `apt` (if the action is running on ubuntu). On Ubuntu it's easy. The issue is, this is windows :( It's going to take lots of commits if I'm to write a good script that installs gmp on that windows by trial and error. Any hint on how to do it "properly"? I mean, is that runner going to install gmp every time it is run? Is there any environment where I can try running the script without making dozens (if not hundreds) of commits? Thank you! – Lluís Alemany-Puig Aug 05 '21 at 12:59
  • There may be some actions [on the Github marketplace](https://github.com/marketplace?type=actions&query=GCC+) to help with the installation (if not, it could be a good opportunity to create one that will be useful to many other users with the same issue). Did you try using another version of windows runner to check if it's installed? – GuiFalourd Aug 05 '21 at 16:26
  • 1
    I didn't try any other version. I just got started two days ago; I didn't even know about GitHub's marketplace :( I'll keep trying – Lluís Alemany-Puig Aug 08 '21 at 04:55

0 Answers0