Blonde Guy

my experience with emx

I'm a programmer; I develop software tools to implement and measure software licensing. We support dozens of platforms, which is a euphemism for UNIX. I've done ports to many versions of UNIX, VMS, NetWare, Windows and NT.

A couple of weeks ago, we made our biggest sale ever, but the sale was contingent on delivery of an OS/2 port.

Our software is written for maximum portability accross UNIX systems. Porting to Windows, NetWare, VMS and NT wasn't easy. A typical UNIX system takes from a day to a week to complete the port of perhaps 100,000 lines of C code. Windows, NT, NetWare and VMS each took several months, and we expected OS/2 to take several months.

I had read on the Web about a version of the gnu C compiler called emx, an environment built to make it easier to move a UNIX program to OS/2.

I tried to assemble emacs and the basic emx development tools from the Hobbes CD-Rom of June 1996. It didn't work. The version of emxrt.dll and the rest of emacs wouldn't cooperate. The documentation refered to patches I would need...

Next, I went directly to ftp://ftp.cdrom.com/pub/os2. This was much better. All of the programs were compatible with each other. First I installed emx runtime. This consisted of unzipping it, and adding the appropriate directories to the path, libpath and bookshelf in config.sys. After rebooting, I seemed to have emx runtime support.

[update: 2004 -- Unfortunately, this resource is no longer available. But an even better online source for emx files has been established at Hobbes.]

I followed this success with the install of emacs and the emx development system. Each of these went in just as emx had gone in. Emacs also required some environment variables, and I threw in the optional emx environment variables as well. After another reboot, I ran a command file in the emacs ...\bin directory which added emacs icons to the desktop. I compiled a test program successfully. Emacs appears to work.

The product had a single make file. I tried to execute this make file the product using gnu make version 3.74. I ran into trouble right away. Gnu make couldn't parse the rules that had "%:RCS/%,v" in them. I didn't think these rules applied to OS/2, so I commented them out of my make file. Things now went quite well until I came to socket code. I needed bsddev.zip added to my emx tools. Once I did this, socket code compiled just fine.

The EMX gnu is pickier about the file sys/types.h before sys/stat.h. It is also pickier about the declaration of sys_errlist in stdlib.h. I changed my code to comply. The whole UNIX project now compiled. I went on to linking. EMX did not provide the ranlib command, so I commented it out in the makefile. I needed to add socket.a to my list of libraries. Some UNIX platforms refer to libraries with an unstated prefix "lib". EMX does not, so I changed the make file again.

OS/2 does not support file system links, so I changed the "ln -s" command in the make file to "cp -p". I had to go into the C code and equate lstat to stat. I changed the directory separator from front slash to back slash, and the path separator from colon to semicolon. A mkdir command in the make file also had to be changed to back slash from front slash.

Back in the make file, some variables have been refered to as $$ID, and this did not work. I change all references to $(ID). I now had to change a "cat" command in the make file to "type". I then changed all of my targets from just the name to the name followed by ".exe". I was making successful executables, but the strip command didn't work. I changed strip to "emxbind -s", and that seems to work. Finally, the setpgrp function was missing. I realized that I didn't really need it on OS/2, and commented it out. I had created the final executable. I started the server program, and it seems to be running normally. Then I started a client program which displayed the server status, and everything looked normal. Even on a UNIX system, it usually doesn't work on the first execution. I ran the same client on a Solaris system, and it also reported that the OS/2 server was normal. In fact, every test I could run showed that this first build was correct.

I step back, and take a deep breath. I've been working for 24 hours, and the port is done. Do I tell my boss? He's budgeted two months. I run the product again. It really works.

last updated: 15 Dec 1997