Patching Marc Rochkind’s Ux library

I’ve begun playing a bit with the Ux library from Marc Rochkind‘s book: Advanced UNIX Programming. Ux, recently mentioned by Bruce as well, is essentially a bunch of C++ wrappers for standard POSIX calls.

Unfortunately, it didn’t build cleanly out of the box. I had to make a number of changes to Ux to get it to compile on my Ubuntu Dapper Drake Linux system with gcc-3.4 and gcc-4.0…

Most of it is because gcc is intolerant of things that are not valid C++, like putting default arguments in the implementation of a function and trying to specify a friend class without using the “class” keyword. There was also some bizarre #ifdef magic in uxprocess.cpp that was causing “uselocale” problems for me in c++locale.h – my guess is this is probably trying to work around some weirdness on some other platform (?), but my system was very intolerant of this stuff.

Also I needed to use -lrt for linking as that’s where the aio_* functions were on my system.

I removed the -Wstrict-prototypes option because otherwise I got this warning:

cc1plus: warning: command line option "-Wstrict-prototypes" is valid 
for Ada/C/ObjC but not for C++

I added -I$(AUPSRC)/common to CFLAGS; for some reason it did not have this, but instead it had -I$(AUPSRC)/c6, which is not necessary.

Also for some strange reason, the makefile referred to a non-existent “nu” directory; I replaced all such instances with “ux”.

The makefile also has some stuff that’s not currently invoked and not correct for building the mms utility from /aup/common/mkmacrostr.c – I’m not sure what this utility is for, but I went ahead and hacked the makefile so that it gets built.

Lastly, I added some really hacky lines that let the makefile build a shared library called libux.so.0.0.0 – the problem is that this stuff is very specific to Linux and would have to change for other platforms. For example, on Mac OS X, shared libraries don’t even have a .so extension; they have a .dylib extension. Another problem is that shared library code on many platforms should ideally be built as PIC (position-independent code) and the support for this and options differ from platform to platform. Libtool would be a nice way to deal with these differences.

Anyway, here’s the patch file.

I’m sending this to Mr. Rochkind and hoping he can use this as a starting point for improving Ux. I also suggested to Mr. Rochkind that putting this on Sourceforge might help as well as using the GNU autotools and building a shared library.

Thanks to Mr. Rochkind for a great book and for making the source code of Ux available!

Advanced UNIX Programming (2nd Edition) (Addison-Wesley Professional Computing Series)

Leave a Reply

Your email address will not be published. Required fields are marked *