Search code examples
xcodemacoscocoamach-o

Where does /usr/include/mach-o/loader.h come from?


It seems that some of my Mac OS X systems have /usr/include/mach-o/loader.h and others don't. I'm confused because this file is documented here:

https://developer.apple.com/library/mac/#documentation/developertools/conceptual/MachORuntime/Reference/reference.html

For example:

...Declared in /usr/include/mach-o/loader.h. See also mach_header_64.

Does anyone know if this file was removed on any newer versions of Mac OS X? Or if I need to install a special SDK to get it?


Solution

  • It exists on my Mac (OS X 10.7), but I do have Xcode installed and it might have come as part of that.

    Edit

    Note that when Xcode compiles anything, it doesn't use the headers in /usr/include but the ones in the SDK you have chosen and you can find out where the system headers are by doing a compile and then checking the -isysroot command line switch. So I have just done a compile and the compiler invocation includes:

    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7sdk
    

    If you open that directory, you'll find it contains a usr/include/mach-o subdirectory with the file you want in it.