Gitlab CI / CD的C ++ 17问题

时间:2020-01-29 13:08:31

标签: c++ c++17 gitlab-ci gitlab-ci-runner

我一直在尝试在我正在使用的库的回购中设置CI / CD。它需要C ++ 17并可以在我的本地计算机上成功编译。但是,当管道在Gitlab上运行时,在编译时会出现此错误。

 $ make check
 Scanning dependencies of target gtest
 [  9%] Building CXX object googletest-build/googletest/CMakeFiles/gtest.dir/src/gtest- 
 all.cc.o
 [ 18%] Linking CXX static library ../../lib/libgtest.a
 [ 18%] Built target gtest
 Scanning dependencies of target mconf
 [ 27%] Building CXX object CMakeFiles/mconf.dir/src/config_option.cpp.o
 [ 36%] Building CXX object CMakeFiles/mconf.dir/src/config_file.cpp.o
 In file included from /builds/USER/config_parser/src/config_file.cpp:1:0:
 /builds/USER/config_parser/src/config_file.hpp:9:10: fatal error: filesystem: No 
 such file or directory
 #include <filesystem>
           ^~~~~~~~~~~~
 compilation terminated.
 CMakeFiles/mconf.dir/build.make:86: recipe for target 
 'CMakeFiles/mconf.dir/src/config_file.cpp.o' failed
 make[3]: *** [CMakeFiles/mconf.dir/src/config_file.cpp.o] Error 1
 CMakeFiles/Makefile2:100: recipe for target 'CMakeFiles/mconf.dir/all' failed
 make[2]: *** [CMakeFiles/mconf.dir/all] Error 2
 CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/check.dir/rule' failed
 make[1]: *** [CMakeFiles/check.dir/rule] Error 2
 Makefile:175: recipe for target 'check' failed
 make: *** [check] Error 2
 ERROR: Job failed: exit code 1

这是我的.gitlab-ci.yml文件。

image: ubuntu:latest

stages:
    - build

before_script:
    - apt update -qq

Build:
    stage: build
    script:
        - apt install -y -qq cmake make git gcc g++
        - mkdir build
        - cd build
        - cmake ..
        - make check
    artifacts:
        paths:
            - public

我还没有更改Gitlab上CI / CD的任何设置。我尝试使用debian:stable,但是我只是从文件系统中获得了指向我正在使用的功能的链接器错误。

1 个答案:

答案 0 :(得分:1)

根据https://hub.docker.com/_/ubuntu/

ubuntu:latest标记指向“最新LTS”,因为这是 建议一般使用的版本。 ubuntu:rolling标记指向 最新版本(与LTS状态无关)。

在撰写本文时,ubuntu:latest对应于Ubuntu 18.04版本,可能太旧了。

尝试ubuntu:rolling,它当前对应于Ubuntu 19.10。