Frida: stdio.h file not found error on macOS Sierra

Created on 11 Sep 2017  路  13Comments  路  Source: frida/frida

macOS Sierra 10.12.6 with Xcode 8.3.3
Followed building instructions, I get gum/meson-private/sanitycheckobjc.m:1:8: fatal error: 'stdio.h' file not found

Checking the isysroot path, stdio.h is present in /usr/include/.

Macbook:frida macbook$ make core-macos
FRIDA_HOST=macos-x86_64 \
        FRIDA_OPTIMIZATION_FLAGS="-Os" \
        FRIDA_DEBUG_FLAGS="-g3" \
        FRIDA_ASAN=no \
        ./releng/setup-env.sh
Environment created. To enter:
# source /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-env-macos-x86_64.rc
. build/frida-env-macos-x86_64.rc && cd frida-gum/bindings/gumjs && npm install

> [email protected] install /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/frida-gum/bindings/gumjs/node_modules/fsevents
> node install

[fsevents] Success: "/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/frida-gum/bindings/gumjs/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
npm notice created a lockfile as package-lock.json. You should commit this file.
added 450 packages in 10.03s
FRIDA_HOST=macos-x86 \
        FRIDA_OPTIMIZATION_FLAGS="-Os" \
        FRIDA_DEBUG_FLAGS="-g3" \
        FRIDA_ASAN=no \
        ./releng/setup-env.sh
Environment created. To enter:
# source /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-env-macos-x86.rc
. build/frida-env-macos-x86.rc \
        && export PACKAGE_TARNAME=capstone \
        && . $CONFIG_SITE \
        && case macos-x86 in \
            *-x86)    capstone_archs="x86"         ;; \
            *-x86_64) capstone_archs="x86"         ;; \
            *-arm)    capstone_archs="arm"         ;; \
            *-arm64)  capstone_archs="aarch64 arm" ;; \
        esac \
        && make -C capstone \
            PREFIX=$frida_prefix \
            BUILDDIR=../build/tmp-macos-x86/capstone \
            CAPSTONE_BUILD_CORE_ONLY=yes \
            CAPSTONE_ARCHS="$capstone_archs" \
            CAPSTONE_SHARED=$enable_shared \
            CAPSTONE_STATIC=$enable_static \
            install
  GEN     capstone.pc
  CC      cs.o
  CC      utils.o
  CC      SStream.o
  CC      MCInstrDesc.o
  CC      MCRegisterInfo.o
  CC      arch/X86/X86DisassemblerDecoder.o
  CC      arch/X86/X86Disassembler.o
  CC      arch/X86/X86IntelInstPrinter.o
  CC      arch/X86/X86ATTInstPrinter.o
  CC      arch/X86/X86Mapping.o
  CC      arch/X86/X86Module.o
  CC      MCInst.o
  AR      libcapstone.a
ar: creating archive /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/tmp-macos-x86/capstone/libcapstone.a
mkdir -p /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86/lib
install -m0644 /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/tmp-macos-x86/capstone/libcapstone.a /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86/lib
mkdir -p /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86/include/capstone
install -m0644 include/*.h /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86/include/capstone
mkdir -p /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86/lib/pkgconfig
install -m0644 /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/tmp-macos-x86/capstone/capstone.pc /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86/lib/pkgconfig/
. build/frida-meson-env-macos-x86_64.rc; \
    builddir=build/tmp-macos-x86/frida-gum; \
    if [ ! -f $builddir/build.ninja ]; then \
        mkdir -p $builddir; \
        python3 /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/releng/meson/meson.py \
            --prefix /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86 \
            --cross-file build/frida-macos-x86.txt \
            --default-library static --buildtype minsize --strip -Denable_diet=auto \
            frida-gum $builddir || exit 1; \
    fi; \
    /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/releng/ninja-macos-x86_64 -C $builddir install || exit 1
The Meson build system
Version: 0.41.0.dev1
Source dir: /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/frida-gum
Build dir: /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/tmp-macos-x86/frida-gum
Build type: cross build
Project name: frida-gum
Native c compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang (clang 8.1.0)
Appending CFLAGS from environment: '-include /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-version.h -fPIC -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9 -arch x86_64 -I/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86_64/include -I/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/sdk-macos-x86_64/include'
Appending LDFLAGS from environment: '-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -Wl,-macosx_version_min,10.9 -arch x86_64 -Wl,-dead_strip -Wl,-no_compact_unwind -L/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86_64/lib -L/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/sdk-macos-x86_64/lib'
Appending CPPFLAGS from environment: '-include /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-version.h -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9 -arch x86_64 -I/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86_64/include -I/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/sdk-macos-x86_64/include'
Cross c compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang (clang 8.1.0)
Native cpp compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ (clang 8.1.0)
Appending CXXFLAGS from environment: '-fPIC -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9 -arch x86_64 -I/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86_64/include -I/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/sdk-macos-x86_64/include -stdlib=libc++ -fno-rtti'
Appending LDFLAGS from environment: '-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -Wl,-macosx_version_min,10.9 -arch x86_64 -Wl,-dead_strip -Wl,-no_compact_unwind -L/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86_64/lib -L/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/sdk-macos-x86_64/lib'
Appending CPPFLAGS from environment: '-include /Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-version.h -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9 -arch x86_64 -I/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/frida-macos-x86_64/include -I/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/sdk-macos-x86_64/include'
Cross cpp compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ (clang 8.1.0)
Host machine cpu family: x86
Host machine cpu: x86
Target machine cpu family: x86
Target machine cpu: x86
Build machine cpu family: x86_64
Build machine cpu: x86_64
/Users/macbook/Dev/Clones/ReversingTools/frida/source/frida/build/tmp-macos-x86/frida-gum/meson-private/sanitycheckobjc.m:1:8: fatal error: 'stdio.h' file not found
#import<stdio.h>
       ^
1 error generated.

Meson encountered an error in file meson.build, line 15, column 2:
ObjC compiler /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang can not compile programs.
make[1]: *** [build/frida-macos-x86/lib/pkgconfig/frida-gum-1.0.pc] Error 1
make: *** [core-macos] Error 2

Most helpful comment

The root reason is missing the /usr/include folder, install command-line tools sometimes will not automatically add it. The Link shows the correct way:
Install the package at
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14. pkg

All 13 comments

I鈥檝e encountered this as well, and resolved it by making sure Xcode鈥檚 command-line tools were properly installed. Could you check if that also resolves it for you?

Thanks @oleavr, running xcode-select --install worked! The command-line tools were working for other things, xcode-select showed the correct path as well , but for some reason that command was required.

Glad to hear! I suspect this happens after an Xcode upgrade, where somehow things go slightly out of sync.

In my case IOS simulator wasn't installed.

Go to Xcode -> Preferences -> Components
Download the latest IOS Simulator.

The root reason is missing the /usr/include folder, install command-line tools sometimes will not automatically add it. The Link shows the correct way:
Install the package at
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14. pkg

The root reason is missing the /usr/include folder, install command-line tools sometimes will not automatically add it. The Link shows the correct way:
Install the package at
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14. pkg

well done. thanks

For anyone discovering this later on who may not be familiar with the command line, here's how to install the macOS_SDK_headers_for_macOS_10.14.pkg package as explained in @yicongli's response above:

In Terminal.app or any shell app like iTerm:

cd /Library/Developer/CommandLineTools/Packages/
open macOS_SDK_headers_for_macOS_10.14.pkg

This should open the following prompt:
image

Make sure you go through the whole thing and try to install the gem that failed to install again or run bundle install again if this was something you encountered while trying to install from a Gemfile.

Olivierlacan your solution worked fine, thanks

@olivierlacan brilliant answer -it solved my problem.

@olivierlacan thanks, man

u da man @olivierlacan

@olivierlacan you're a lifesaver

@olivierlacan solution worked like a charm!
I was having problems with

import theano

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nkoneko picture nkoneko  路  3Comments

ehsanpc9999 picture ehsanpc9999  路  4Comments

packmad picture packmad  路  4Comments

SajjadPourali picture SajjadPourali  路  4Comments

spacex97 picture spacex97  路  3Comments