How to Compile a Simple OpenGL Program (Part I : Symantec C++ 7)

The other day, I was searching through my collection of discs and was distracted by a shiny thing: Symantec C++ 7.

Symantec C++ 7 is a complete development environment for Windows 16-bit & 32-bit and runs under MS-DOS, Windows 3.1, Windows NT, & Windows 95. While looking through the contents of the disc, I spied an OpenGL samples folder with one specifically named Book which I believe to be a reference to The Book.

I’ve always been fascinated by computer graphics so I decided to see how this compiler, released in 1995, held up today and try out the samples. The software includes an installer but more importantly, a folder is included on the disc from which the compiler and IDE can be run directly making this task easy to accomplish.

I copied the SC folder (BIN, HELP, INCLUDE, LIB, SAMPLES, etc.) to the local hard drive and then wrote a command script to set the environment for it:

@echo off
title Symantec C++ 7
set SYMANTEC7=C:\Tools\Symantec7
set include=%SYMANTEC7%\Include
set lib=%SYMANTEC7%\Lib
path %SYMANTEC7%\bin;%SYMANTEC7%\redist32;%PATH%
echo ----------------------------------------------------------
echo SCW32 : Windows 32-bit front-end
echo ----------------------------------------------------------

I also placed a shortcut in the Start Menu to execute the command script with the following settings:

Shortcut Name: Symantec C++ 7

Target: %COMSPEC% /k C:\Users\Public\bin\Symantec7.cmd

Start In: C:\Tools\Symantec7\Samples\win32

Comment: Set environment for Symantec C++ 7 for Windows

Icon: %SystemDrive%\Tools\Symantec7\bin\SCW32.EXE,0

I started SCW32 (the 32-bit version of the IDE) and voila! I opened up one of the OpenGL projects, compiled, and executed it:

OpenGL Sample of an array of teapots with different material colors.

OpenGL sample of an array of teapots with different material colors.

Very cool. In looking at the project definition, I noticed it was a single C file. Knowing there were 69 68 individual projects, I wondered how I could simplify this so it would be easier to compile all the examples. Fortunately, in addition to the project files, which are proprietary to Symantec C++, there are makefile equivalents for each project. Unfortunately, the make utility included with Symantec can’t seem to build them (I’ll figure out why at some other point in time).

The easier solution for the time being was to figure out what information the compiler needed to compile each source file into an executable. Reading through the makefiles for the options and linkage and then experimenting lead me to this:

sc -mn -C -WA -S -3 -a8 -g TEAPOTS.C glaux.lib glu32.lib opengl32.lib gdi32.lib

Here’s an explanation of the command line options used for Symantec C++ 7:

Memory model = Win32s, Windows 95, Windows NT
No inline function expansion
Windows Executable
Always generate stack frame
80386 code (4 : 80486; 5 : Pentium)
Alignment of struct members
Generate debug info
glaux.lib glu32.lib opengl32.lib gdi32.lib
The libraries necessary for linking

Armed with this knowledge, there are a couple of ways to compile all the examples. The simplest method is to use a shell “for” loop:

for %c in (*.c) do sc -mn -C -WA -S -3 -a8 -g %c glaux.lib glu32.lib opengl32.lib gdi32.lib

Interestingly, this works fine in Windows XP and all the examples compile. But in Windows 7 (64-bit), as it loops through each source file, some examples will compile, others generate an “OPTLINK” exception, and then the compiler will finally hang. The exceptions and hanging seem to be arbitrary as they occur at different points in the loop. Yet, no problems are encountered if each command is executed manually.

An example of the OPTLINK exception.

An example of the OPTLINK exception.

The “for” loop could be speeded up by pre-compiling the headers beforehand with the -HX compiler option.

Another method would be to create a makefile to incorporate all the projects with dependencies to build all & clean all. I’ll leave this as an exercise to perform at a later time.

In the end, this was a fun exercise getting to know an old friend. I’m surprised at how well the compiler (SC) has held up through the years despite all the changes made Windows but even more so that the IDE (SCW32) functions so well. Even though the size of the buttons and dialogs point to a time where 800×600 was king, the interface was ahead of its time and maybe even better than Visual Studio in some ways.

My interest in OpenGL has also been rekindled, especially in regards to Android, although I consider my desires to be more experimental in nature. I’m not a graphics artist so I don’t believe I’ll be publishing anything serious. But it’s still fun to play with.

The next step is to compile these examples with Visual Studio but before doing so, I’m going to slight detour into some history which involves Teapot

~ by bwsd on May 22, 2010.

One Response to “How to Compile a Simple OpenGL Program (Part I : Symantec C++ 7)”

  1. Update: I discovered there are 68 individual projects and 1 master. Unfortunately, while I can successfully load the master project and build all using SCW32 on Windows XP, the same can not be said of Windows 7. Individual projects can be loaded and built but not the master.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: