# Use Clang without GCC's C++ standard library

**URL:** https://discourse.nixos.org/t/use-clang-without-gccs-c-standard-library/9884
**Category:** Development
**Created:** [November 7, 2020, 2:21pm UTC](https://discourse.nixos.org/t/use-clang-without-gccs-c-standard-library/9884 "2020-11-07T14:21:14Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![timjrd](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@timjrd](https://discourse.nixos.org/u/timjrd)
#### Post date: [November 7, 2020, 2:21pm UTC](https://discourse.nixos.org/t/use-clang-without-gccs-c-standard-library/9884/1 "2020-11-07T14:21:14Z")

</div>

Hi everyone 🙂  
I hope I’m posting in the right category.

I’m trying to build a C++ package on NixOS with `clangStdenv` (the source code is coming from macOS and it doesn’t seems to compile with GCC). But I’m getting errors because Clang is pulling GCC’s C++ standard library instead of Clang’s one (the project I’m working on is using things like `std::powf` which are not in GCC’s std).

Any idea? Thanks!

---

<div class="post-metadata">

### Author: ![bhipple](https://discourse.nixos.org/user_avatar/discourse.nixos.org/bhipple/32/201_2.png) [@bhipple](https://discourse.nixos.org/u/bhipple)
#### Post date: [November 7, 2020, 2:44pm UTC](https://discourse.nixos.org/t/use-clang-without-gccs-c-standard-library/9884/3 "2020-11-07T14:44:40Z")

</div>

I’m not sure if it answers your specific question, but it’s worth checking out @mic92’s recent deep dive into C/C++ infrastructure if you’re going to be playing around with it:

> [@Nix Friday - streaming about Nix every Friday](https://discourse.nixos.org/t/nix-friday-streaming-about-nix-every-friday/4655/84):
>
> This Nix Friday I will be in the stream as well and we will talk about the C/C++ infrastructure in nixpkgs. We won’t talk too much about the language itself, but how the compilers/linkers are integrated into stdenv and how the build system abstraction works. If you happen to package C/C++ applications or libraries, this should give you a good overview. If you have any question you want to answered, please post them here: [Nix Friday: C/C++ questions for next stream](https://discourse.nixos.org/t/nix-friday-c-c-questions-for-next-stream/9692)

---

<div class="post-metadata">

### Author: ![timjrd](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@timjrd](https://discourse.nixos.org/u/timjrd)
#### Post date: [November 7, 2020, 2:51pm UTC](https://discourse.nixos.org/t/use-clang-without-gccs-c-standard-library/9884/4 "2020-11-07T14:51:28Z")

</div>

Thanks! In fact I answered my own post, but the reply got flagged as spam, this did the trick for me:

```auto
with import <nixpkgs> {};
(clangStdenv.override (x: {
  cc = x.cc.override (_: {
    libcxx = llvmPackages.libcxx;
  });
})).mkDerivation {
  # ...
}

```

---

<div class="post-metadata">

### Author: ![gebner](https://discourse.nixos.org/user_avatar/discourse.nixos.org/gebner/32/321_2.png) [@gebner](https://discourse.nixos.org/u/gebner)
#### Post date: [November 8, 2020, 10:57am UTC](https://discourse.nixos.org/t/use-clang-without-gccs-c-standard-library/9884/5 "2020-11-08T10:57:18Z")

</div>

You might want to look at `libcxxStdenv`.

---

<div class="post-metadata">

### Author: ![timjrd](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@timjrd](https://discourse.nixos.org/u/timjrd)
#### Post date: [December 3, 2020, 11:59pm UTC](https://discourse.nixos.org/t/use-clang-without-gccs-c-standard-library/9884/6 "2020-12-03T23:59:27Z")

</div>

Thanks! `libcxxStdenv` is working perfectly.
