OpenGL and X11

Mark Brethen mark.brethen at gmail.com
Fri Aug 30 14:09:47 UTC 2019


I tried using macports libraries mesa and freeglut and patched the Makefile:

CFLAGS = -O2 -Wall \
  -I./ \
  -I/opt/local/include \
  -I/opt/local/include/GL \
  -I../../libSNL/src \
  -I../../glut-3.5/src \
  -I/opt/X11/include

LFLAGS = \
  -L/opt/local/lib -lGL -lGLU \
  -L/opt/X11/lib -lX11 -lXi -lXmu -lXext -lXt -lSM -lICE \
  -lm -lpthread


# on 32bit systems change lib64 to lib
# -lpthread is needed if mesaGL is using threading, otherwhise it is not needed
# -L/usr/X11/lib64 -lpthread -lX11 -lXext -lXi -lXmu -lXt -lSM -lICE \

include Makefile.inc

ULIB = \
 userFunction.c

SUTIL = \
 uselibSNL.cpp \
 generateTet.cpp \
 ../../libSNL/src/*.cpp

OLIB = $(SLIB:.c=.o)
OULIB = $(ULIB:.c=.o)
OUTIL = $(SUTIL:.c=.o)

cgx: $(OLIB) $(OUTIL) $(OULIB)
	$(CXX)  $(OULIB)  $(OLIB) $(OUTIL)  $(CFLAGS) $(LFLAGS) -o  $@

But this failed to build with the following error

:info:build Undefined symbols for architecture x86_64:
:info:build   "_glutVisibilityFunc", referenced from:
:info:build       _main in cgx.o
:info:build ld: symbol(s) not found for architecture x86_64
:info:build clang: error: linker command failed with exit code 1 (use -v to see invocation)

So I’ll stick with using Apple’s framework OpenGL and GLUT.

Mark Brethen
mark.brethen at gmail.com



> On Aug 29, 2019, at 7:32 PM, Mark Brethen <mark.brethen at gmail.com> wrote:
> 
> I'm using macports to install OpenGL (mesa) since High Sierra does not have the X11 parts of it. In the Makefile there are includes and LFLAGS that need to be patched:
> 
> diff -ur cgx_2.13/src.orig/Makefile cgx_2.13/src/Makefile
> --- cgx_2.13/src.orig/Makefile	2018-04-05 13:32:06.000000000 -0500
> +++ cgx_2.13/src/Makefile	2018-12-11 20:50:49.000000000 -0600
> @@ -3,13 +3,13 @@
>   -I/usr/include \
>   -I/usr/include/GL \
>   -I../../libSNL/src \
>   -I../../glut-3.5/src \
> -  -I/usr/X11/include 
> +  -I/opt/X11/include
> 
> LFLAGS = \
> -  -L/usr/lib64 -lGL -lGLU \
> -  -L/usr/X11R6/lib64 -lX11 -lXi -lXmu -lXext -lXt -lSM -lICE \
> -  -lm -lpthread -lrt
> +  -framework OpenGL -framework GLUT \
> +  -lX11 -lXi -lXmu -lXext -lXt -lSM -lICE \
> +  -lm -lpthread
> 
> This seems to work but I’m not sure it's proper.
> 
> Mark Brethen
> mark.brethen at gmail.com
> 
> 
> 



More information about the macports-dev mailing list