Gitlab 的 C++17 问题 CI/CD
C++17 problems with Gitlab CI/CD
我一直在尝试在我正在处理的库的存储库中设置 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,但我在文件系统中使用的函数出现链接器错误。
根据https://hub.docker.com/_/ubuntu/
The ubuntu:latest tag points to the "latest LTS", since that's the
version recommended for general use. The ubuntu:rolling tag points to
the latest release (regardless of LTS status).
在撰写本文时,ubuntu:latest
对应于 Ubuntu 18.04 版本,可能太旧了。
尝试ubuntu:rolling
,目前对应Ubuntu 19.10.
我一直在尝试在我正在处理的库的存储库中设置 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,但我在文件系统中使用的函数出现链接器错误。
根据https://hub.docker.com/_/ubuntu/
The ubuntu:latest tag points to the "latest LTS", since that's the version recommended for general use. The ubuntu:rolling tag points to the latest release (regardless of LTS status).
在撰写本文时,ubuntu:latest
对应于 Ubuntu 18.04 版本,可能太旧了。
尝试ubuntu:rolling
,目前对应Ubuntu 19.10.