Compile error, stdatomic.h not found

I'm just throwing this out here, in case someone has any idea how to progress.

I'm trying to cargo install difftastic in Linux, which makes the compiler use the cc crate to do some custom compilation for the libmimalloc-sys crate. This custom compilation errors because the file stdatomic.h can't be found.

Internet searches reveals that I need GCC v4.9 or newer [1], and the system I use have v4.8.5 by default.
It is not my system so I can't upgrade GCC, but I am able to use GCC v10.2.0 from a custom path. But adding this newer GCC to the front of my PATH in my env doesn't change the compilation result.

The README for the cc crate [2] reveals that I can force the compiler used by setting the CC variable. So I try the following:
CC=/path/to/gcc/10.2.0-2/bin/gcc cargo install difftastic --force

This seems to fix the compilation problem, but instead I get a cascade of linker errors:
error: linking with cc failed: exit status: 1

This is as far as I got.
Any tip would be appreciated.

[1] c - <stdatomic.h> in GCC 4.8? - Stack Overflow

What are the linker errors you are getting?

The linker errors filled the whole screen.
But I will see if I can see something specific in them that I can post here.

I could not see anything specific to pick out, so here is a link to a pastebin.

I think gcc is not able to find the C++ standard library. I'm not familiar enough with this to know how to fix that though.

The cc crate also checks the CXX environment variable to find a C++ compiler. You could try setting it to your custom path g++.

Thanks for all the tips, everyone.

@bjorn3 It looks like at least the stdlib files exists in the custom path. But yeah, I don't know how to troubleshoot this either.
/path/to/gcc/10.2.0-2/bin/gcc <-- The gcc binary
/path/to/gcc/10.2.0-2/include/c++/10.2.0/ <-- This looks like stdlib files

@MoAlyousef I tried to also add the path to CXX, but no difference. I also tried to use CXX without also using CC, but that gave me my first error (as if I hadn't use CC or CXX at all).

The libmimalloc-sys crate is compiling So I tried to compile that one separately by cloning into the repo with git.

Using the following made it compile without any problems. it is the same CC and CXX flags I tried using with cargo. Weird that I don't get the same result.

mkdir -p out/release
cd out/release
CC=/path/to/gcc/10.2.0-2/bin/gcc CXX=/path/to/gcc/10.2.0-2/bin/g++ cmake ../..