How to get gcc-4.8 binary instead of gcc

I’m trying to set up development environment for C++ project to develop in CLion.

CMake in CLion tells me what:

  1. It cannot get compiler compilation, because it cannot run gcc-4.8 and g+±4.8
  2. c-ares library not found…

I though what if I created shell.nix file, with gcc48 and c-ares buildInputs, and launched CLion from nix-shell shell.nix created environment my problems would be solved.
Shell.nix I have created looks like this:

with import {}; {
qpidEnv = stdenvNoCC.mkDerivation {
name = “my-gcc4.8-env”;
buildInputs = [ pkgs.c-ares pkgs.gcc48 ];

Which gcc returns /nix/store/-gcc-wrapper-4.8.5/bin/gcc
gcc --version returns

How should I modify my shell.nix file, so what CLion by looking for gcc-4.8 find my gcc which is of version 4.8?

p.s. In ubuntu I would just do ln -s which gcc /bin/gcc-4.8. Whats the thought process to solving paths problems in NixOS?
p.s.s. I am sorry for bad grammar as english is not my native language. Thank you for your time!

Instead of using a stdenv that does not have a GCC at all, try stdenvGCC48 (actual name might be slightly different, I’m writing this from memory).

you’re looking for:

with import {}; {
qpidEnv = gcc48.stdenv.mkDerivation {
name = “my-gcc4.8-env”;
buildInputs = [  ];

gcc --version gives 4.8,
but environment still doesn’t have gcc-4.8 and as a result, project fails compiling.

Can you perhaps share a more complete example of what you are trying to build?

Maybe I could do something like @Mic92 has done here?
How would what look like?

1 Like