# Xcode 14: can't find libc.h when building via Make

**URL:** <https://discourse.cmake.org/t/xcode-14-cant-find-libc-h-when-building-via-make/7451>\
**Category:** Code\
**Tags:** os:macos\
**Created:** [February 13, 2023, 1:56am UTC](https://discourse.cmake.org/t/xcode-14-cant-find-libc-h-when-building-via-make/7451 "2023-02-13T01:56:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew](https://discourse.cmake.org/user_avatar/discourse.cmake.org/andrew/32/2478_2.png) [@Andrew](https://discourse.cmake.org/u/Andrew)\
**Post date:** [February 13, 2023, 1:56am UTC](https://discourse.cmake.org/t/xcode-14-cant-find-libc-h-when-building-via-make/7451/1 "2023-02-13T01:56:08Z")

</div>

Building C code for MacOSX. Have a file that references libc.h.

Xcode 13 (with command line tools installed): built fine from Xcode or Make

Xcode 14 (with command line tools installed): builds fine from Xcode. Fails to build from make with error that libc.h cannot be found.

libc.h exists in /Applications/Xcode.app/Contents//Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libc.h but I don’t know how to make sure that CMake with the default generator can find this.

Xcode 14.2  
CMake 3.24.2

---

<div class="post-metadata">

**Author:** ![Andrew](https://discourse.cmake.org/user_avatar/discourse.cmake.org/andrew/32/2478_2.png) [@Andrew](https://discourse.cmake.org/u/Andrew)\
**Post date:** [February 13, 2023, 2:12am UTC](https://discourse.cmake.org/t/xcode-14-cant-find-libc-h-when-building-via-make/7451/2 "2023-02-13T02:12:19Z")

</div>

I think it might be some sort of caching issue.

- Updated to 3.25.2
- Ran cmake . in the build directory to regenerate everything.

Got a warning:

> CMake Warning at /Applications/CMake.app/Contents/share/cmake-3.25/Modules/Platform/Darwin-Initialize.cmake:303 (message):  
> Ignoring CMAKE\_OSX\_SYSROOT value:
> 
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk
> 
> because the directory does not exist.  
> Call Stack (most recent call first):  
> /Applications/CMake.app/Contents/share/cmake-3.25/Modules/CMakeSystemSpecificInitialize.cmake:21 (include)  
> CMakeLists.txt:3 (project)

And the CMakeTestCCompiler.cmake failed.

Did a fresh build in a fresh directory and it worked.

I had assumed running “cmake .” in the build directory would reconfigure the entire project, but it seems not.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [February 13, 2023, 5:20am UTC](https://discourse.cmake.org/t/xcode-14-cant-find-libc-h-when-building-via-make/7451/3 "2023-02-13T05:20:37Z")

</div>

When the compiler changes, it is recommended to start fresh if anything goes wrong (CMake already does this if the compiler _path_ is detected to have changed). This includes updating Xcode as paths found and cached may need to be rediscovered as the SDK details that get cached can change over time (as you found out).

> [@Andrew](#):
>
> I had assumed running “cmake .” in the build directory would reconfigure the entire project, but it seems not.

It does, but knowing what cache values are stale is a hard problem.
