Compiling Applications with Otk
You can either compile your application and Otk in one step, or compile Otk and link your application separately.
- Compiling in one step:
(This is how many of the initial example applications are set up.)
- Include Otk_lib.c directly into your program - Somewhere near the top of your program, place:
#include "otk_lib/otk_lib.c"
- Compile your program as normal,
but you may need to add some compile options described in Compiling OTK below.
For example, on Linux:
cc -I/usr/X11R6/include -L/usr/X11R6/lib yourprogram.c -lGLU -lGL -lXmu -lXext -lX11 -lm -o yourprogram
Or,
- Compiling Otk and linking with your application separately:
(This is usually recommended for good style and long-term efficiency.)
- Compile Otk_lib.c with -c option to make Otk_lib.o .
See Compiling OTK below.
For example: cc -c otk_lib.c -o otk.o
- Compile and link with your application.
For example: cc myapp.c otk.o -lGLU -lGL -lXmu -lXext -lX11 -lm -o myapp.exe
To Compile on Unix/Linux:
Be sure to link with -lGLU -lGL and -lX11.
For example, to compile on Linux:
cc -O -I/usr/X11R6/include -L/usr/X11R6/lib yourprogram.c -lGLU -lGL -lXmu -lXext -lX11 -lm -o yourprogram
To compile on Sun Solaris
gcc -O -I/usr/dt/include -L/usr/dt/lib yourprogram.c
-lGLU -lGL -lXmu -lXext -lX11 -lm -o yourprogram.exe
To Compile on Microsoft, MinGW is recommended:
The platform auto-detection will automatically detect MinGW and compile the right sections.
See Downloading & installing MinGW, and compiling Otk with MinGW
To Compile on Microsoft using MS-Visual-C:
Not sure if auto-platform detect will work in this case.
Otherwise, set PLATFORM_KIND to MsVisC_Platform.
Compile as console application. Needs Glut libs.
(See Microsoft Visual-C.)
Other Notes:
- Determining Otk version from your application - Over the life of Otk,
some things may change. It may be helpful
for your application code to know which version of Otk it is presently
using. There is a global Otk variable called Otk_version which
will always hold the version value in floating point.
If you included Otk_lib.c, then access Otk_version as a global value.
If you linked Otk_lib.o, then declare Otk_version as an extern float and
access as a global. For example:
extern float Otk_version;
if (Otk_version > 0.90) printf("Newer Otk lib.\n");
Back to main page