[Mesa-users] Linking OSMesa and GL

Haavard Holm haavard.holm at ntnu.no
Wed Aug 10 10:24:47 UTC 2016


Hi Frédéric,

and thank you for a fast and good answer !

To me your first option seems most attractive. I will therefore give it 
a try :
I have configured/compiled mesa :
mesa-11.0.7 $ ./configure --enable-mangling --disable-dri3 
--enable-osmesa --enable-static --disable-dri
then the 'make/make install' command - and all seems to be ok.
I include GL/gl_mangle.h
in my source, but end up with error messages like :
OpenGL.cxx:93:24: error: 'mglEnable' was not declared in this scope
    mglEnable(GL_LIGHTING);
                         ^
OpenGL.cxx:96:26: error: 'mglColor3f' was not declared in this scope
    glColor3f(1.0, 1.0, 0.0);


Line 93 in my code is :
    glEnable(GL_LIGHTING);

What seems to be the problem here ?

Best regards
Håvard




On 09. aug. 2016 22:06, Frédéric Devernay wrote:
> Hi
>
> Since most OSMesa functions and libGL functions have the same name, the first one on the command-line will take precedence.
>
> You have two options:
> - link both libraries, but use a mangled OSMesa (and a mangled GLU if you're using GLU). Mangled OSMesa can be linked statically in this case. You can the either called the mangled OSMesa functions directly (mgl... instead of gl...), or use OSMesaGetProcAddress to get the entry points and store them in pointers to functions which you use in your OpenGL code.
> - open the non-mangled OSMesa library from your program using dlopen() (on Unix), and get the entry point for OSMesaGetProcAddress using dlsym(), and then get the various OpenGL entry points using OSMesaGetProcAddress. You cannot use GLU in this case (because GLU calls the OpenGL functions directly), except if the OSMesa is mangled, in which cas you can use a mangled GLU.
>
> I have a script which installs a static osmesa (mangled or not) with the driver of your choice and a few patches for mesa 11.1-12.0 at https://github.com/devernay/osmesa-install
> --
> Frédéric Devernay, Research Scientist, INRIA
> frederic.devernay at inria.fr
>
>
>
>
>> Le 9 août 2016 à 20:25, Haavard Holm <haavard.holm at ntnu.no> a écrit :
>>
>>
>> Hello,
>>
>> I have made a program, running under fltk and using the GL-libraries.
>>
>> To add some features it seems handy to use OSMesa. I have however problems using both libraries.
>>
>> If I link with -lOSMesa -lGL -lGLU, my OSMesa features work fine, but my other OpenGL windows turn black.
>> If I link with -lGL -lGLU -lOSMesa, gives the oposite result.
>>
>> How can this be fixed ? Are there a way to handle this problem ?
>>
>> Best regards
>> Håvard Holm
>>
>>
>> _______________________________________________
>> mesa-users mailing list
>> mesa-users at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-users




More information about the mesa-users mailing list