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
Answer from William D. Irons on Stack OverflowI'm not sure how exactly the packages relate, but I needed to install the gcc package to resolve some sort of load error. Given that gcc didn't produce any results, I ran a quick
Copy$ conda search gcc
Which yielded, among other things, gcc_linux-64. After
Copy$ conda install gcc_linux-64
My issue went away, despite the fact that which gcc still pointed to the system install 🤷♂️
I had to install two conda packages to fix this issue:
Copy$ conda install gcc_linux-64
$ conda install gxx_linux-64
Just to share, not sure it will help you. However it shows that in standard conditions it is possible to use the conda gcc as described in the documentation instead of the system gcc.
# system gcc
which gcc && gcc --version
# /usr/bin/gcc
# gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
# creating a conda env with gcc
conda create -n gcc gcc
# activate the environment
conda activating gcc
which gcc && gcc --version
# /opt/conda/envs/gcc/bin/gcc
# gcc (GCC) 11.2.0
Here is the list of packages installed on a fresh environment created with only gcc.
# packages in environment at /opt/conda/envs/gcc:
#
# Name Version Build Channel
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 1_gnu conda-forge
binutils_impl_linux-64 2.36.1 h193b22a_2 conda-forge
gcc 11.2.0 h702ea55_2 conda-forge
gcc_impl_linux-64 11.2.0 h82a94d6_11 conda-forge
kernel-headers_linux-64 2.6.32 he073ed8_15 conda-forge
ld_impl_linux-64 2.36.1 hea4e1c9_2 conda-forge
libgcc-devel_linux-64 11.2.0 h0952999_11 conda-forge
libgcc-ng 11.2.0 h1d223b6_11 conda-forge
libgomp 11.2.0 h1d223b6_11 conda-forge
libsanitizer 11.2.0 he4da1e4_11 conda-forge
libstdcxx-ng 11.2.0 he4da1e4_11 conda-forge
sysroot_linux-64 2.12 he073ed8_15 conda-forge
In addition to the solution posted in this issue. I added symbolic-links that point to the conda installed gcc, which I was missing.
ln -s /home/envs/segmentation_base/bin/x86_64-conda_cos6-linux-gnu-cc gcc
ln -s /home/envs/segmentation_base/bin/x86_64-conda_cos6-linux-gnu-cpp g++