OS/2 eZine - http://www.os2ezine.com
July 16, 2002
James Cannon actively served 12 years in the U.S. Army with a broad range of experience from programming COBOL on a mainframe, to networking simulators with UNIX, and supervising a small IT shop. He continues military service in the U.S. Army Reserve. He is currently working for Agilent Technologies as a "Technical Lead" overseeing the backup operations of 5000+ HP-UX and Windows clients. He is happily married, a proud father, and never gets enough keyboard and mouse time with OS/2 Warp.

If you have a comment about the content of this article, please feel free to vent in the OS/2 eZine discussion forums.

There is also a Printer Friendly version of this page.

Previous Article
Next Article

Do you have an OS/2 product or service you'd like to advertise?

EMX on the Desktop

If you have tried EMX, but missed all the goodies that come with a commercial compiler, such as an IDE, or a toolbox, you're not alone. Chances are you've made all the proper adjustments to your CONFIG.SYS file, or you decided to use the newer WarpIN installation. Then you eventually come to the "... what now?" stage. You've read all the online help, but you really prefer some nice desktop objects to work for you. Now, this is going to be a whole lot about getting started. If you're an avid Warp or eCS user, and you're not programming yet, now is the time to learn. The EMX package can get you programming big time, with only your efforts being the major expense. I'm going to help you with that.

First thing I do is go and clean the CONFIG.SYS file. When I mean clean, I mean getting rid of any unnessary variables, directives, or other modifiers to your OS/2 environment. So I may be breaking the rules here by "disabling" the EMX runtime support. The fact is, when bandwidth was low, programs needed to be small in size to aid in data transfer. Whether it was through the older floppy "sneaker net" or slow modem service. Personally, I preferred the old Linux way of doing things, by distributing source code and compiling on your own using the author's instructions. Programs written with EMX need not use the runtime. Alright, I know I'm sounding crazy here, but with future changes to the GNU C Compiler (GCC), this may be a good idea as the old and trusty EMX runtime may no longer be compatible with future versions of GNU software running on OS/2. I'm not trying to be an alarmist, but there is active development on GCC that cannot be ignored. So, if you're a developer, say goodbye to dynamic linked libraries and create a complete product. As EMX changes, so can you.

So it is time to fire up that OS/2 System Editor, or your favorite text editor. The first thing is to figure out how to get the EMX runtime working in an OS/2 Window. If you've read the online help already, you are way ahead of the game. For the rest of you, you're missing out on some good OS/2 reading. As a bonus, it is free! Yeah, Baby, Yeah! If you've read the documentation that came with the EMX runtime, you'll see "Add \emx\dll to LIBPATH", "Add \emx\bin to PATH", and "Reboot". Let's take a look at this further. In your OS/2 Window (you should always have one open), type HELP LIBPATH and press enter. OS/2 responds with the online help exactly on the right page for you. You should see "Related Commands" containing BEGINLIBPATH and ENDLIBPATH. These are the keys to cleaning out your CONFIG.SYS file. What these two variables do is allow you to modify your LIBPATH statement without a reboot being necessary. Well, that is only half the story. Let's check out PATH, by typing HELP PATH in that OS/2 Window. Now let's take what we know and put it to work for us:

OK, that was pretty cool. Next, we'll want to add all of the other variables mentioned in the \emx\doc\emxgnu.doc:

set BEGINLIBPATH=e:\emx\dll PATH e:\emx\bin;%path%; set C_INCLUDE_PATH=e:\emx\include set LIBRARY_PATH=e:\emx\lib set CPLUS_INCLUDE_PATH=e:\emx\include\cpp;e:\emx\include set OBJC_INCLUDE_PATH=e:\emx\include set PROTODIR=e:\emx\include\cpp\gen set TMPDIR=e:\tmp\ set GCCLOAD=5 set GCCOPT=-pipe set TERM=mono set TERMCAP=E:\emx\etc\termcap.dat

Now I happen to have EMX on my E:\ drive, so make the appropriate changes and save it in your \emx directory as EMX.CMD. I've put mine in E:\emx\emx.cmd. Do what suits you. Let's test this EMX.CMD in that OS/2 Command Window and see what we get: (NOTE: If you don't want or need a verbose display of the commands, place an @ sign in front of any commands you don't want to see. You could also add the emxrev command at the end to ensure you have a valid session.)

Of course, I've added a splash of color to my window by manipulating some ASCII settings. For the most part I have the environment the way I want it. Now, let's put this aside for a moment and get back to creating the Desktop object.

First, we may need a folder, an editor, online help, and of course an OS/2 Window with the environment set just right. So, it's time to move to your Templates folder (located in OS/2 System on the Warp 4 desktop). First, let's drag a folder object to our desktop, or to some other convenient location, such as the Programs folder. Next, we'll access its Properties and give it a decent title:

Once you have that folder in a convenient location, we'll need to drag some program objects to the new EMX folder from the templates folder. You'll instantly be greeted with the properties of this new object. Enter * in the "Path and file name", to invoke the OS/2 command processor. Next, and this is important, enter /k E:\emx\emx.cmd. What the "/k" option does, is execute a command file at the location specified by the text following the "/k". This is the power of OS/2 we've all come to love in the Workplace Shell (WPS): an incredibly customizable interface. While we have the Properties open, go to the Icon tab and give it a name. I've called mine, "emx Command Window".

Now that's done, let's get an editor in there too. Drag another program object from the Templates folder. I am going to use what is currently installed on my system, but if you have a preferred editor, use that. I really enjoy the Enhanced Editor, so I've entered EPM.EXE and modified the working directory. Modifying the working directory makes saving files easy as it will default to this location.

Once that is taken care of, I've associated this new object with .C, .CC, .H, and .RC files. The Enhanced Editor has built in features for C code. If you start typing code for a case, if, or other statement, it will do some of the typing for you. This will need to getting used to, but that is the power of computers: automation! Once that is done, give the object a nifty name on the Icon tab. I'm going with emx Code Editor. Use what suits you best.

Now we have the rudiments of a code hackers workbench. Once you get going you'll want easy access to online help, unless you enjoy typing HELP EMX in that new "emx Command Window". So, let's start dragging some more program objects from the Templates folder. You can use the browse feature to find the info in your \emx\book folder. There are five, so I won't go into the details on each one. Just give them suitable titles to aid you. Here is my properties for my "Users Guide to the emx Runtime" (the "PAth and file name" used is the VIEW.EXE for OS/2's built-in help system):

Once all of these objects have been created, we are pretty much done. Here is a final shot of the end product:

Now there is a lot more stuff to put in our new folder. On Hobbes is a program to manage projects, but would require the use of make (preferably GNU's make). If you are planning on doing some Presentation Manager programs, Dr. Dialog may be something else to include. You could even create your own templates of skeleton C/C++ programs. Then all you had to do is drag and drop it to a location, add more code, and compile. This is only a starting point. Sure, you could spend some money elsewhere, but why? If you ever had to reinstall or perform multiple copies of a desktop object, you'll know there is a better way: REXX. I've included a EMXinst.CMD for those of you with an aversion to the Templates folder. Happy coding.

Previous Article
Next Article

Copyright (C) 2002. All Rights Reserved.