[HOpenGL] problems compiling hopengl on freebsd

Sven Panne Sven_Panne@BetaResearch.de
Thu, 29 Aug 2002 10:52:40 +0200


Chris Moline wrote:
> [...] then i tried compiling it with
> 
> gcc test.c -I/usr/X11R6/include -lSM -lICE  -L/usr/X11R6/lib -lX11 -lXext
> -lXmu -lXt -lXi  -lm -pthread -lGL
>
> this compiles with no errors. running ./a.out gives hello world!. [...]

I assume that FreeBSD uses Mesa as its OpenGL implementation. During Mesa's
build it is tested if compiling with <pthread.h> and linking with -lpthread
gives access to pthread_create. In that case, a thread-safe variant of Mesa
is built (thread-safe dispatch, per-thread OpenGL context, etc.). Of course
this requires linking any OpenGL application with pthreads.

Plausible as this explanation is, I've got no idea why the explicit
-pthread is needed only for FreeBSD, perhaps some FreeBSD guru can
enlighten me. Maybe I have to adjust the configure magic one more
time. *sigh*

The fix is simple (Bourne shell syntax):

   LDFLAGS="-pthread" ./configure

Cheers,
   S.