# gcc on mac can't build cmake

**URL:** https://discourse.cmake.org/t/gcc-on-mac-cant-build-cmake/4755
**Category:** Development
**Created:** [January 1, 2022, 11:53am UTC](https://discourse.cmake.org/t/gcc-on-mac-cant-build-cmake/4755 "2022-01-01T11:53:07Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![iwata](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/i/c67d28/32.png) [@iwata](https://discourse.cmake.org/u/iwata)
#### Post date: [January 1, 2022, 11:53am UTC](https://discourse.cmake.org/t/gcc-on-mac-cant-build-cmake/4755/1 "2022-01-01T11:53:07Z")

</div>

I hope #include \<memory\> is added to cmMachO.h. ‘string’ of libc++ includes ‘memory’. But ‘string’ of libstdc++ does not. As a result, though clang can compile cmMachO.cxx, gcc can not. Consider please.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [January 2, 2022, 7:50am UTC](https://discourse.cmake.org/t/gcc-on-mac-cant-build-cmake/4755/2 "2022-01-02T07:50:19Z")

</div>

Nothing in `cmMachO.h` needs anything from the `memory` header. All it needs is `std::string`, for which `string` is the correct C++ header to include. The `cmMachO.cxx` file includes `cm/memory`, which does include `memory`. It sounds to me like you might be using a misconfigured compiler, possibly mixing headers from multiple compilers.

---

<div class="post-metadata">

### Author: ![iwata](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/i/c67d28/32.png) [@iwata](https://discourse.cmake.org/u/iwata)
#### Post date: [January 2, 2022, 9:19am UTC](https://discourse.cmake.org/t/gcc-on-mac-cant-build-cmake/4755/3 "2022-01-02T09:19:21Z")

</div>

Thank you for reply. When version became 3.16, Internal, which is a member of cmMachO and defined in the last line of cmMachO.h, changed to a smart pointer. \<memory\> is required before this line. cmMachO.h is included at the top of cmMachO.cxx. So, #include \<cm/memory\> after #include \<cmMachO.h\> is late. Is this interpretation wrong?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [January 2, 2022, 10:05am UTC](https://discourse.cmake.org/t/gcc-on-mac-cant-build-cmake/4755/4 "2022-01-02T10:05:48Z")

</div>

Ah, yes you are correct. I missed the `std::unique_ptr`. That looks like a bug, I’ll see if I can put a fix together for it.

---

<div class="post-metadata">

### Author: ![iwata](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/i/c67d28/32.png) [@iwata](https://discourse.cmake.org/u/iwata)
#### Post date: [January 2, 2022, 10:09am UTC](https://discourse.cmake.org/t/gcc-on-mac-cant-build-cmake/4755/5 "2022-01-02T10:09:23Z")

</div>

Thank you very much!

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [January 2, 2022, 10:17am UTC](https://discourse.cmake.org/t/gcc-on-mac-cant-build-cmake/4755/6 "2022-01-02T10:17:51Z")

</div>

Please try the branch in [merge request 6835](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6835).
