In order to use the C++17 include <filesystem>
I need gcc-9 package in my centos 7 docker.
By default centos:7 will install gcc 4.8.5 from the regular distro repo.
docker run --rm -it centos:7
# yum install -y gcc
# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Is there any way to easily install a gcc-9 (or later) package (i.e. not build it from source)
Thanks !
note: need gcc-9 to have good C++17 <filesystem>
support.
GCC 9 Release note:
Using the types and functions in
<filesystem>
does not require linking with-lstdc++fs
now.
2
Answers
What I have so far:
cat Dockerfile
So you must:
Add the source stuff in a bashrc
note: On Centos it's
/etc/bashrc
while on ubuntu it's/etc/bash.bashrc
Update the docker default shell to be bash AND to "load" the bashrc using
--login
Output
What won't work
Test 1
each
RUN
is a new shell so the sub-bash is lost on the second line.Test 2
Here again the source is only for the first RUN shell command but will be lost...
Test 3
This may work but with potential unexpected behaviour
here we only "fix" the
PATH
variable but if you look at the/opt/rh/devtoolset-9/enable
script there is so more to do than only updating thePATH
...You may give it a try using the below steps if that may help:
Download the latest package from http://ftp.gnu.org/gnu/gcc/gcc-9.2.0/
Extract the files using the steps below:
Build a configuration using the below,
Compile the installation using make and then make install.