[prog] OpenGL/Mesa/Glut

Sue Stones suzo at bigpond.net.au
Sat Jun 21 16:12:59 EST 2003


Thanks James, I realised what the problem was when I woke up this morning.
(Interesting how the solution to a problem often comes overnight).  Thanks
for confirming it.  Thanks also for the explanation of how to solve it.

Why does the CFLAGS and LDFLAGS have to be on one line? Is this because it is
entered at the comand line?  I assume thta on separate lines within the
makefile would be OK.  I will no doubt find this out.

sue

On Sat, 21 Jun 2003 01:09 am, James Sutherland wrote:
> From: "Sue Stones" <suzo at bigpond.net.au>
>
> > Well, now I have a problem with the next step.
> >
> > Once I got rid of all the difiult compile errors like writing 'colour'
>
> instead
>
> > of 'color', and the object files are produced. I get a problem with the
> > includefiles again.
> >
> > The problem is that when it tries to compile the next stage I get a whole
> > string of error messages saying things like
> > "undefined reference to `glColor3f'"
> > for each of the functions from OpenGL.
> >
> > What could be the problem here???
>
> Almost the same problem you had with the C compiler and the header files.
>
> When you build your project, first the compiler compiles your C source into
> object files (from foo.c -> foo.o). It needs header files to do this, which
> are included using #include from a directory specified using the -I switch
> on the compiler's command line.
>
> Next, you have to 'link' the .o files into a single executable (from
> foo.o -> foo). This is done by the linked (ld). It needs library files (.so
> or .a) to do this - each library is identified using a -l switch, from a
> directory identified with a -L switch.
>
> Normally, these flags are added to the LDFLAGS variable for your makefile,
> just as you did with CFLAGS for the compiler flags. Just find the name of
> the library, and which directory it lives in; I think it's something like
> libMesaGL.so from /usr/X11/lib:
>
> So:
>
> CFLAGS="(whatever you put here earlier)" LDFLAGS="-lMesaGL -L/usr/X11/lib"
> make all
>
> (All on one line, in case the mailer split it.)
>
> Note you drop the "lib" and ".so" (or ".a") from the filename, so to link
> against libfoo.so you would use the switch -lfoo (one of the GNU libraries
> is named libiberty.so, which makes you compile all that code using the
> "-liberty" switch!)
>
> As a quick check, you can use grep to find the files which mention the
> function name you're after. So:
>
> $ cd /usr/X11/lib
> $ grep -c glColor3f *|fgrep -v :0
> libMesaGL.so:4
> libOSMesa.a:2
> libOSMesa.so:2
> libOSMesa.so.4:2
> libOSMesa.so.4.0:2
>
> Here, the libraries libMesaGL.so and libOSMesa.(so|a|so.4|so.4.0) mention
> this function - linking against one of them (or both) should give the right
> results!
>
>
> James.

-------------------------------------------------------



More information about the Programming mailing list