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 Overflow
Top answer
1 of 1
15

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

🌐
Anaconda
anaconda.org › gouarin › gcc-7
Gcc 7 - conda install
Conda · Files · Labels · Badges · License: GPL · Home: http://gcc.gnu.org/ 2989 total downloads · Last upload: 7 years and 4 months ago · linux-64 v7.2.0 · To install this package run one of the following: conda install gouarin::gcc-7
🌐
Anaconda
anaconda.org › creditx › gcc-7
Gcc 7 | Anaconda.org
Last upload: 7 years and 2 months ago · linux-64 v7.1.0 · To install this package run one of the following: conda install creditx::gcc-7
🌐
Anaconda.org
anaconda.org › conda-forge › gcc
gcc - conda-forge | Anaconda.org
Install gcc with Anaconda.org. GNU C native compiler (symlinks)
🌐
Stack Overflow
stackoverflow.com › questions › 67944627 › how-to-make-use-of-conda-environments-gcc-7-5-0
python - How to make use of conda environment's GCC 7.5.0? - Stack Overflow
June 12, 2021 - I suspect if I get conda environment use gcc 7.5.0, I may fix the cython error. ... I think you're confusing the compiler used to compile an executable with what's installed in the system. Whoever packaged anaconda used gcc 7.5.0 to build anaconda, but that doesn't mean it includes the compiler in the binary.
🌐
RAPIDS
docs.rapids.ai › notices › rdn0002
Updates to from-source builds with conda for gcc '7.5.0' - RAPIDS Docs
February 11, 2021 - In order to build with conda dependencies from conda-forge the installed libstdc++6 package must be >= 9.3.0. You can verify the current installed version and available version through the following commands: sudo apt-get update sudo apt-cache policy `libstdc++6` If the version is not >= 9.3.0 install the package again to update it: ... For CentOS and RHEL we build gcc 7.5.0 from source for our docker images and make it available as a tarball.
🌐
GitHub
github.com › Archiconda › build-tools › issues › 2
how to install gcc-7.3 or gcc-7.2? · Issue #2 · Archiconda/build-tools
December 24, 2018 - @jjhelmus I've managed to make the first package, toolchain, but it seems I need a compatible version of libgcc-ng. I can't find the feedstock for that one. It looks from the notes that you cross c...
Author   Archiconda
🌐
GitHub
gist.github.com › goldsborough › d466f43e8ffc948ff92de7486c5216d6
Instructions for installing GCC >= 4.9 for PyTorch Extensions · GitHub
For those who don't have root access and are in a conda environment, do this: conda install -c psi4 gcc-5 · It works for me!!! Thanks! ... # CentOS 7 sudo yum install centos-release-scl sudo yum install devtoolset-7-gcc* scl enable devtoolset-7 ...
Find elsewhere
🌐
Stack Exchange
unix.stackexchange.com › questions › 698886 › gcc-11-installation-error-in-centos-7-environmental-changes
linux - GCC-11 installation error in centos 7 (environmental changes)? - Unix & Linux Stack Exchange
April 12, 2022 - I installed the latest version of GCC 11.2V using conda, conda install -c conda-forge gcc" in my linux server (Centos7). After I try to login into my server, after login it shows some weird ...
🌐
Anaconda.org
anaconda.org › conda-forge › repo › installers
conda-forge | Anaconda.org
A community-led collection of recipes, build infrastructure, and distributions for the conda package manager. ... To install packages from this channel, use the channel temporarily with conda or add it to your .condarc file for configured ongoing access.
🌐
Conda
docs.conda.io › projects › conda-build › en › latest › resources › compiler-tools.html
Anaconda compiler tools — conda-build 0.0.0.dev0+placeholder documentation
The compiler packages can be installed with conda. Because they are designed with (pseudo) cross-compiling in mind, 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.
🌐
Conda
docs.conda.io › projects › conda-build › en › 3.21.x › resources › compiler-tools.html
Anaconda compiler tools — conda-build 3.21.7+0.gb98d7ec0.dirty documentation
The compiler packages can be installed with conda. Because they are designed with (pseudo) cross-compiling in mind, 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.
🌐
GitHub
github.com › conda › conda-build › issues › 2530
[question] gcc 7.2 conda packages are installed on a Ubuntu 16.04.3 LTS with gcc 5.4 · Issue #2530 · conda/conda-build
November 28, 2017 - However, neither my conda_build_config.yaml nor command line specify version of the compiler - I'd assume it should be deducted from the environment. So, on Ubuntu 16.04.3 LTS, I got errors like g++: error: unrecognized command line option ‘-fno-plt’. This probably happens because of these packages: The following NEW packages will be INSTALLED: binutils_impl_linux-64: 2.28.1-h04c84fa_2 binutils_linux-64: 7.2.0-hc67e822_15 ca-certificates: 2017.08.26-h1d4fec5_0 certifi: 2017.11.5-py36hf29ccca_0 gcc_impl_linux-64: 7.2.0-hc5ce805_2 gcc_linux-64: 7.2.0-haf1f6fa_15 gxx_impl_linux-64: 7.2.0-hd3faf3d_2 gxx_linux-64: 7.2.0-h2e50c1c_15
Author   conda
🌐
Ask Ubuntu
askubuntu.com › questions › 1134266 › whats-the-command-to-find-out-version-of-gcc-is-used-inside-a-conda-virtual-env
python - What's the command to find out version of gcc is used inside a conda virtual environment? - Ask Ubuntu
April 16, 2019 - So to reprase my question, can we use the gcc inside the virtual to compile the program? or do I have to install gcc inside the env? (yourenvname) ~$gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.2.0-8ubuntu3.2' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 -
🌐
Doe
mfix.netl.doe.gov › doc › mfix › 19.2.0 › getting_started › install-linux.html
2.3. Linux Installation — MFiX 19.2.0 documentation
January 11, 2021 - If you don’t have root access on your system, you alternatively could install GCC and GNU Make through Anaconda with: ... To build and run MFiX with DMP, you will need an MPI implementation installed, such as OpenMPI. To install OpenMPI on Ubuntu/Debian derived distributions: ... If you are using a shell different from bash, switch to bash before activating the environment. ... > conda env create -n mfix-19.2 mfix/mfix-19.2-linux64 > conda env list # conda environments: # base * /home/user/anaconda3 mfix-19.2 /home/user/anaconda3/envs/mfix-19.2 > conda activate mfix-19.2 (mfix-19.2) > conda env list # conda environments: # base /home/user/anaconda3 mfix-19.2 * /home/user/anaconda3/envs/mfix-19.2 (mfix-19.2) > mfix
Top answer
1 of 2
2

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
2 of 2
0

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++
🌐
Anaconda
anaconda.org › quantstack › gcc-7
Login :: Anaconda.org
I forgot my password. I forgot my username. Register for an account · By data scientists, for data scientists
🌐
Narkive
conda.continuum.narkive.com › QB7lx2xd › using-the-gcc-package
[conda] Using the gcc package
The recipe is at https://github.com/conda/conda-recipes/tree/master/gcc-4.8. To answer your question, post install scripts are possible with conda, but it's highly preferable to avoid them if possible, as they add a high degree of potential for breakage to the package install process.