How to get a free OS/2 compiler
by Abram Dancy
EMX is a GNU programming environment which has been ported to OS/2. It includes the gcc compiler (although another compiler could be used), and can be used to create PM programs. (A PM program is a Presentation Manager program, that opens a window in the OS/2 environment, as opposed to a text-mode program.) Programs written with EMX can be made to be either stand-alone (the executable file can be run without any other files installed) or can make use of the EMX run-time library (which decreases executable size). Many (excellent) freeware programs require EMX, which means that they make use of the EMX run-time library, EMX.DLL.
EMX (along with a great deal of OS/2 software) can be found at the ftp site hobbes.nmsu.edu (directory: os2/unix/emx09a). There is a file in that directory called INSTALL.DOC which, unsurprisingly, describes how to install EMX on your system. (To see the list of files in any directory with subdirectories get the file 00indexd.txt in that directory.) Basically, you need to get the appropriate zip files (more on that later), move them to your root directory, unzip them, and figure out which environment variables to set. GNU programs are generally pretty good about creating the appropriate directories and subdirectories when you unzip them. (I use info-zip 5.12, available in os2/archiver in the same ftp sites listed above. Wondering how to unzip unzip? Try unzipping it at athena by typing 'unzip unz512x2.zip'. You may need to 'add sipb' first.)
I don't want to describe each of the files in the emx09a directory here, but here are some pointers.
- emxrt.zip contains the files you need to run a program which uses the EMX run time library.
- emxdev.zip, gnudev.zip and gppdev.zip will give you most of what you need to write C++ programs.
- emxview.zip contains EMX documentation in OS/2's inf format.
You may also want to get a make utility, to automate compiling and linking programs (this will be useful just to compile the example EMX programs). The two such utilities I know of are dmake and gnumake, available on hobbes and cdrom.
Glancing at my config.sys file, it seems the changes to my environment variables I needed for emx were adding emx\bin to my PATH, and adding emx\dll to my LIBPATH.
Writing PM programs
To my knowledge, most GUI operating systems make use of dynamically linked libraries (DLL files) to run programs which use the graphical interface. What this means is that your program, when compiled, needs to know what the GUI interface calls look like (what variables it takes as arguments and returns) but does not add the actual code for these functions to your executable file. Therefore, all you need to compile a PM program are the header files giving prototypes for the GUI functions; you do not need any special libraries. EMX includes the header file os2.h to allow you to compile a PM program. You will also need a resource compiler (RC.EXE) to add resources, such as menus and icons, to your programs. RC comes with Warp (at least I think that's how it got in my OS2 directory), although I have found zero in the way of documentation on it.
From a practical standpoint of course, you as a programmer need more information about writing PM programs than just a header file. Included among the EMX sample files is a VERY simple PM program. I would recommend getting a book to learn how to program for the OS/2 interface. One place around MIT to find such books is at Microcenter, which is about a half mile down Memorial Drive past Tang and Westgate. I have Advanced OS/2 Presentation Manager Programming, which contains several example programs and describes generally how things are done in OS/2 PM programs. However, it makes no attempt to describe all the functions you will need to know. I noticed that the sample programs from this book are contained in the apmpro.zip file in the MIT User's Group directory on Athena. I was not able to use the makefiles contained in the book to compile my programs (which I would imagine are the same files as in apmpro.zip), because they assume you are using C Set, not EMX. If you want to see the makefiles I used, contact me.