Search code examples
ioscreact-nativemacospod-install

MacOS Sonoma - configure: error: cannot run C compiled programs


Writing, because all the solutions I tried didn't work.

  • Project framework: React Native (Expo managed)
  • MacOS: Sonoma 14.5
  • XCode: 15.4
  • Chip: M2 Pro

Error:

⚠️  Something went wrong running `pod install` in the `ios` directory.
Command `pod install` failed.
└─ Cause: /bin/bash -c 
set -e
cd sqlite-src-3450300
./configure
make sqlite3.c sqlite3.h sqlite3ext.h

checking build system type... arm-apple-darwin23.5.0
checking host system type... arm-apple-darwin23.5.0
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... 
configure: error: in `/Users/datachanturia/Library/Caches/CocoaPods/Pods/Release/sqlite3/3.45.3+1-02d1f/sqlite-src-3450300':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details


pod install --repo-update --ansi exited with non-zero code: 1


Solution

  • Solution:

    1. Open zshrc: nano ~/.zshrc
    2. Add export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
    3. Save changes and go back
    4. Run source ~/.zshrc

    TL;DR

    It may be very tricky, it can not run, because in my case was compiling incorrectly.

    I created C "Hello World" program with zsh terminal and tried compiling it with clang. Every time I tried to run, system was killing it.

    To find the issue, I created C program in XCode, and ran it. It ran without issues, then found compiled file by XCode moved to exact same directory as "Hello World" program before (with cp command): it ran without issues.

    Here I understood problem wasn't how or from where compiled files run, but how they were compiled.

    I logged XCode build & terminal build and found that, SDKROOT difference was the cause: I had some other path, when XCode was using /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk.

    So adding this path to SDKROOT solved the issue.

    P.S. 2 Days wasted on this