I wanted to install updated version of gcc on a server where I do not have root access. I tried
conda install -c creditx gcc-7
which was not working. Then I found
conda install -c anaconda gcc_linux-64
in fact installs gccv7.3. But after the successful installation, the conda environment still uses the system gcc at
/usr/bin/gcc
Please help me so that I can use the gcc v7.3 that I just installed.
As explained here: https://docs.conda.io/projects/conda-build/en/latest/resources/compiler-tools.html
1) All of the executables in a compiler package are "prefixed." Instead of gcc, the executable name of the compiler you use will be something like x86_64-conda_cos6-linux-gnu-gcc
2) Many build tools such as make and CMake search by default for a compiler named simply gcc, so we set environment variables to point these tools to the correct compiler.
So if you run:
conda create -n cc_env gcc_linux-64
conda activate cc_env
ls $CONDA_PREFIX/bin
You will see a bunch of compiler tools with the prefixed name:
c89 x86_64-conda_cos6-linux-gnu-ct-ng.config x86_64-conda_cos6-linux-gnu-gcov-dump x86_64-conda_cos6-linux-gnu-objdump
c99 x86_64-conda_cos6-linux-gnu-dwp x86_64-conda_cos6-linux-gnu-gcov-tool x86_64-conda_cos6-linux-gnu-ranlib
x86_64-conda_cos6-linux-gnu-addr2line x86_64-conda_cos6-linux-gnu-elfedit x86_64-conda_cos6-linux-gnu-gprof x86_64-conda_cos6-linux-gnu-readelf
x86_64-conda_cos6-linux-gnu-ar x86_64-conda_cos6-linux-gnu-gcc x86_64-conda_cos6-linux-gnu-ld x86_64-conda_cos6-linux-gnu-size
x86_64-conda_cos6-linux-gnu-as x86_64-conda_cos6-linux-gnu-gcc-ar x86_64-conda_cos6-linux-gnu-ld.bfd x86_64-conda_cos6-linux-gnu-strings
x86_64-conda_cos6-linux-gnu-cc x86_64-conda_cos6-linux-gnu-gcc-nm x86_64-conda_cos6-linux-gnu-ld.gold x86_64-conda_cos6-linux-gnu-strip
x86_64-conda_cos6-linux-gnu-c++filt x86_64-conda_cos6-linux-gnu-gcc-ranlib x86_64-conda_cos6-linux-gnu-nm
x86_64-conda_cos6-linux-gnu-cpp x86_64-conda_cos6-linux-gnu-gcov x86_64-conda_cos6-linux-gnu-objcopy
This is ok because environment variables like CC and CPP are pointing to the compiler to use, and commands like make know to use these variable:
$ echo $CC
/home/builder/anaconda3/envs/cc_env/bin/x86_64-conda_cos6-linux-gnu-cc
$ echo $CPP
/home/builder/anaconda3/envs/cc_env/bin/x86_64-conda_cos6-linux-gnu-cpp
For more info on what environment variables make is aware of see: https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With