我用C++编写了一个库,它实现了几个不同的coroutine原语,库的目标是新发布的C++20,因此,它还使用了C++20中添加到语言中的概念。
我想使用github操作来构建库,但是构建失败了,因为ubuntu-latest使用GCC 9和CLang 9,但是我的库至少需要GCC 10或Clang 10来构建。
我试图通过设置-DCMAKE_CXX_COMPILER=g++-10来配置构建操作,但是由于在系统上找不到g++-10,所以该操作在配置CMake阶段失败。
有没有办法指定github动作应该使用GCC 10或Clang 10?
这是我尝试运行的最新工作流文件:
name: CMake
on: [push]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{runner.workspace}}/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{runner.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_COMPILER=g++-10
- name: Build
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Test
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE这就是它失败的地方:
Run cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_COMPILER=g++-10
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
The CMAKE_CXX_COMPILER:
g++-10
is not a full path and was not found in the PATH.
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "/home/runner/work/conduit/build/CMakeFiles/CMakeOutput.log".
See also "/home/runner/work/conduit/build/CMakeFiles/CMakeError.log".
##[error]Process completed with exit code 1.发布于 2020-08-26 22:15:05
正如一些程序员所提到的,从apt安装g++是可行的方法(除非默认情况下是安装的);在构建中增加一两分钟。然后,您可以通过在配置步骤中传递CC和CXX变量来告诉cmake它应该使用哪个编译器:
- run: |
sudo apt update
sudo apt install gcc-10 g++-10
shell: bash
# ... #
- run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
shell: bash
env:
CC: gcc-10
CXX: g++-10当您想使用clang时,也会应用相同的解决方案。
发布于 2020-12-20 22:21:06
我使用gcc-9和clang-10作为C(仅)项目.
- name: Setup dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get install -y gcc-9 llvm-10 clang-10
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-9 100 \
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-9 \
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-9 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-9
sudo update-alternatives \
--install /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-10 100 \
--slave /usr/bin/llvm-ranlib llvm-ranlib /usr/bin/llvm-ranlib-10 \
--slave /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-10
sudo update-alternatives \
--install /usr/bin/clang clang /usr/bin/clang-10 100你需要更新更多的C++项目的替代方案,举个例子。
发布于 2022-01-31 01:50:56
通过访问https://github.com/actions/virtual-environments,您可以看到安装了什么。
如果您在2022年尝试,现在 ubuntu-latest有"GNU C++ 9.3.0,10.3.0“。g++链接到版本9,但是g++-10在路径上是可用的,无需任何额外的安装步骤。
https://stackoverflow.com/questions/63606079
复制相似问题