1. Jason McKesson
  2. glLoadGen
  3. Issues
Issue #29 resolved

Compilation errors on Mac OS X

Romain Giraud
created an issue

Hello,

I am trying to compile generated files on Mac OS Mountain Lion :

lua glLoadGen/LoadGen.lua -style=pointer_cpp -spec=gl -version=2.1 -profile=core ../src/gl/core

First of all, NS* functions are deprecated (used in AppleGLGetProcAddress function). I use this function extract from here.

static void* AppleGLGetProcAddress (const char *name)
{
    static void* image = NULL;
    if (NULL == image)
        image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY);

    return (image ? dlsym(image, (const char *)name) : NULL);
}

The compiler can't convert "const char" to "const GLubyte" (aka "const unsigned char*"). So we can use this code to convert it :

const GLubyte *temp = 0;
return AppleGLGetProcAddress(temp);

Regards Romain

Comments (8)

  1. Jason McKesson repo owner

    I am not certain how this:

    const GLubyte *temp = 0;
    return AppleGLGetProcAddress(temp);
    

    Helps anything. The name is rather important; sticking NULL in there won't be helpful. Converting to const GLubyte * should be nothing more than a simple cast.

  2. Robert Menzel

    The function loader works on MacOS X when issue #31 is fixed (see there) and either in the current 'AppleGLGetProcAddress' the parameter gets changed to 'const char name' and the malloc gets a cast to (char) (works even with warnings about the deprecated function) or the solution from Romain Giraud:

    The new function would be:

    #include <dlfcn.h>
    
    static void* AppleGLGetProcAddress (const char *name)
    {
        static void* image = NULL;
        if (NULL == image)
            image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY);
    
        return (image ? dlsym(image, name) : NULL);
    }
    

    Note the changed include! This is all that has to be changed, no 'const GLubyte *temp = 0;'! As this seems not to be deprecated and also the code is much smaller, this is probably the way to go.

  3. computerquip

    Given the age of this bug, has a decision been made concerning this? While it works, it generates an line error for every single extension, which in my case seems to generate a 600kb compile log. I think it should be given more precedence.

  4. Log in to comment