I'm trying to get the version of Mac OS X programmatically in C. After searching for a while I tried this code: 

```
#include <CoreServices/CoreServices.h>

int GetOS()
{
    SInt32 majorVersion,minorVersion,bugFixVersion;

    Gestalt(gestaltSystemVersionMajor, &majorVersion);
    Gestalt(gestaltSystemVersionMinor, &minorVersion);
    Gestalt(gestaltSystemVersionBugFix, &bugFixVersion);

    printf("Running on Mac OS X %d.%d.%d\n",majorVersion,minorVersion,bugFixVersion);    

    return 0;
}

```

XCode returns an LD error:

`Undefined symbols for architecture x86_64:
 "_Gestalt", referenced from:
 _GetOS in main.o`

What am I missing? How do you do this?

I found also this snippet

```
[[NSProcessInfo processInfo] operatingSystemVersionString]

```

But I have no idea how to write that in C.