title: Replacement for NSAddImage (in GLLoadGen)
body: <p>The GL loader generated with GLLoadGen contains the following code:</p>
  
  <pre><code>static void* AppleGLGetProcAddress (const GLubyte *name)
  {
    static const struct mach_header* image = NULL;
    NSSymbol symbol;
    char* symbolName;
    if (NULL == image)
    {
      image = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR);
    }
    /* prepend a '_' for the Unix C symbol mangling convention */
    symbolName = (char*)malloc(strlen((const char*)name) + 2);
    strcpy(symbolName+1, (const char*)name);
    symbolName[0] = '_';
    symbol = NULL;
    /* if (NSIsSymbolNameDefined(symbolName))
       symbol = NSLookupAndBindSymbol(symbolName); */
    symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL;
    free(symbolName);
    return symbol ? NSAddressOfSymbol(symbol) : NULL;
  }
  </code></pre>
  
  <p>This function apparently loads the address of the OpenGL function <code>name</code>. However the calls to <a href="https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/MachOReference/Reference/reference.html" rel="nofollow">NSAddImage and related</a> are deprecated since OSX 10.5. What is the current (non-deprecated) approach to load the function addresses?</p>