I am starting to write a couple of lines of code to learn a bit of OpenGLon my laptop with Ubuntu 10.10. Having a laptop with a Quadro FX 1800, I would like to use the Nvidia driver. However, if I understand correctly, Nvidia doesn’t support the DRI interface, which is needed by Mesa. So I have to use the files provided by the nvidia-common-dev package. That probably also means that it’s better to remove Mesa, since they provide the same files.
So I removed Mesa. But now how do I install GLUT? The freeglut that comes with Ubuntu is based on Mesa, which is not what I want. I tried to compile freeglut by myself, but I get an error about the file GL/glu.h missing. This file comes with Mesa, but it doesn’t seem to come with Nvidia.
Any information that can help me to move on is appreciated.
I think the only way to add glu.h is to add Mesa.
It seems actually that it’s quite a common procedure to have Mesa and the Nvidia drivers together. It looks a bit dodgy to me, since I would be using Mesa’s files with Nvidia’s drivers, whereas Mesa and Nvidia provide different OpenGL implementations. Besides, I would have a gl.h coming from Mesa and one coming from Nvidia.
I think I’ll try to put Mesa back in, and see what happens. But I have to say I’m not very happy about it.
I would be glad to know this thing works.
Don’t offend Ubuntu!
I couldn’t find a lot of information about Gentoo, but it seems to have a bit the same problem, in the sense that you need Mesa and the drivers together. It could get rid of the repeated OpenGL files though.
Okay, so I have now Nvidia and Mesa. I have two gl.h, libGL.so and other files. However, it seems that I can do everything just using Mesa’s header files, although if I use Nvidia’s it seems to work as well.
ldconfig has Nvidia directories at the top, so Nvidia shared libraries are loaded first.
The conclusion of all this is: it works, but there is definitely room for improvement.
Exactly and gentoo successfully manages the various versions of these header files, i.e. if you install and use mesaGL you’ll get symbolic links to mesa libs and header files, if you use nvidiaGL (you tell so using the eselect utility), you’ll get symbolic links to nvidia’s header files and libs.
Ubuntu just sucks for C++ development, that’s my opinion.
Maybe I should explain myself.
A header file exposes an interface, and gives information about how the interface is implemented by a library. However, there doesn’t need to be an exact match between what the header offers and what the library offers. A header file can do some extra work. This means that while the methods declared in two header files, the ones that you call, have to be the same, the methods implemented in two libraries don’t.
Therefore, unless stated otherwise by a specification or a standard, I wouldn’t say it’s safe to assume that you can freely use a header file coming from a different library. Sure, it can be expected that it works, but I wouldn’t say it’s correct.
At the end I’m accepting the situation as is, so I can live with it; after all, it’s not the first time it happens. But if I had to be a bit more difficult I would say that the idea of mixing Mesa and Nvidia like that doesn’t make me completely happy. I’d like to use Mesa’s headers with Mesa’s libraries, and Nvidia’s headers with Nvidia’s libraries. And if I use GLUT, which is compiled against Mesa, I would like to use it with Mesa, not with Nvidia.
I understand what you mean. But Mesa follows the OpenGL standard, so it will always provide the good interface for developing with GL, unless you use old implementation of Mesa.
For example, ATI proprietary drivers only provide the library and not the headers, but therefore, require Mesa to be installed. Nvidia prefered to provide their own headers. On Windows you have to put the latest GL headers, or at least, “define” yourself the missing declarations.
After, Linux distributions can provide their own package for proprietary drivers and do “what they want”, like making symlinks of them.
okay, I have to say that I did look at the specification before posting, but after reading about this ATI thing I looked again.
After some digging I found this, which looks quite interesting. There I found:
This document is intended to solve two related problems. First, defining the ABI and runtime environment for applications using OpenGL under X11 on Linux. This will enable applications using the OpenGL API for rendering to run on a variety of underlying implementations transparently. The intent is to address all of open source, commercial closed binary, OpenGL SI-based, and Mesa-based implementations.
Second, defining the SDK for developing apps using OpenGL. This includes header file locations, conventions for use of extensions, etc.
The document is quite old, but doing some extra digging I found that it’s still followed, since the Nvidia installer has 2 options that mention that page when talking about the include and lib directories (something where, by the way, Ubuntu fails).
The installer also explains why Nvidia is giving its own headers:
Normally, installation will not install NVIDIA’s OpenGL header files; the OpenGL header files packaged by the Linux distribution or available from http://www.opengl.org/registry/ should be preferred. However, http://www.opengl.org/registry/ does not yet provide a glx.h or gl.h. Until that is resolved, NVIDIA’s OpenGL header files can still be chosen, through this installer option.
So it looks like the specification does define a bit more than just the methods, after all. Shame that it’s not complete though.
Well, I think I figured that out. Something learned, problem solved. Guess I’m happy