HP Workstation zx2000 HP OpenGL Implementation Guide for HP-UX 11.X (IPF versi - Page 32

including header files, linking shared libraries, HP Graphics Administration Guide

Page 32 highlights

compiling and linking programs including header files Most OpenGL programs and applications that use only the standard OpenGL data types, definitions, and function declarations, need include only the header file gl.h. To include this file, use the following syntax: #include Still other header files may be needed by your program, depending on your application. For example, in order to use the OpenGL extension to X Windows (GLX) you must include glx.h, as shown below. #include Instructions for including various additional header files are usually provided with the README file that accompanies a utility or function. The README also includes instructions for using or operating the utilities. Your header file declarations at the beginning of your program should look similar to this: #include #include #include #include #include #include #include #include linking shared libraries OpenGL is supported using shared libraries that must be linked with the application program. When you compile your OpenGL programs, you must link the application with the OpenGL library libGL. Notice that the OpenGL library is dependent on the HP X extensions library (libXext). An ANSI C compile line will typically look similar to this: cc -Ae -I/opt/graphics/OpenGL/include \ -I/usr/include/X11R6 -o cube.32 cube.c \ -L/opt/graphics/OpenGL/lib/hpux32 \ -L/usr/lib/hpux32/X11R6 -lGLU -lGL -lXhp11 -lXext -lX11 -lm To compile your application using ANSI C, you can also use the cc command with either of the command line options -Aa or -Ae. If you are going to compile your application using HP's ANSI C++ compiler, use the aCC compiler. See the HP Graphics Administration Guide for more information on compiling. 4-2 OpenGL implementation guide

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

4–2
OpenGL implementation guide
compiling and linking programs
including header files
Most OpenGL programs and applications that use only the standard OpenGL data types,
definitions, and function declarations, need include only the header file
gl.h
. To include this
file, use the following syntax:
#include <GL/gl.h>
Still other header files may be needed by your program, depending on your application. For
example, in order to use the OpenGL extension to X Windows (GLX) you must include
glx.h
,
as shown below.
#include <GL/glx.h>
Instructions for including various additional header files are usually provided with the
README
file that accompanies a utility or function. The
README
also includes instructions for using or
operating the utilities.
Your header file declarations at the beginning of your program should look similar to this:
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <GL/gl.h>
#include <GL/glx.h>
linking shared libraries
OpenGL is supported using shared libraries that must be linked with the application program.
When you compile your OpenGL programs, you must link the application with the OpenGL
library
libGL
. Notice that the OpenGL library is dependent on the HP X extensions library
(
libXext
).
An ANSI C compile line will typically look similar to this:
cc -Ae -I/opt/graphics/OpenGL/include \
-I/usr/include/X11R6 -o cube.32 cube.c \
-L/opt/graphics/OpenGL/lib/hpux32 \
-L/usr/lib/hpux32/X11R6 -lGLU -lGL -lXhp11 -lXext -lX11 -lm
To compile your application using ANSI C, you can also use the
cc
command with either of the
command line options
-Aa
or
-Ae
.
If you are going to compile your application using HP’s ANSI C++ compiler, use the
aCC
compiler.
See the
HP Graphics Administration Guide
for more information on compiling.