WindowMaker as the X11 window manager

My light-weight window manager of choice is WindowMaker.  It is simple, easy to modify, and stays out of the way.  The default window manager installed with X11 on FreeBSD, however, is twm.  I first experienced twm in the Virginia Tech Computer Science Dept. UNIX lab (all FreeBSD boxes), and tvm looks exactly the same today.  I cannot pick on it too much, however.  The guy in the office next door to me at work uses tvm on his Linux box.  I suppose I ought to call it an Emacs box, since he does everything out of emacs.  I digress…

Please read this excellent tutorial on xinit and .xinitrc files from the Fluxbox project first.  The tutorial explains very clearly how the xinit program works and how .xinitrc files are processed.  In short, however, once the end of .xinitrc is reached, X11 is shutdown.  Thus you need a blocking command in xinitrc scripts that prevents the script from exiting.  In the default xinitrc script,  /usr/X11R6/lib/X11/xinit/xinitrc, I noticed towards the bottom of the script:

twm &

It was followed by three xterm commands. The first two were also run in the background, but the final xterm was not run in the background, thus preventing X11 from terminating until that terminal is closed by the user.  No more twm on this box though!  I removed the xterm commands, and changed the twm line to the following:

wmaker

Now, WindowMaker is launched and until the user exits the WindowMaker session X11 will continue to run. All users on my FreeBSD will have WindowMaker when the execute startx.  I also created a .xinitrc in my user account home directory as follows:

exec wmaker

In reality, however, I have XDM to run as my “magic client” (see article linked above). Instead of managing a separate .xinitrc and .xsession file, I just symlinked the files together so that any changes are available in both files, in the cast that I ever disable XDM.

ln -s .xinitrc .xsession

After I log into the system via XDM, my .xsession file is executed and WindowMaker is launched.

Setting up XDM

The X Display Manager, or XDM, is a program that allows one to log into a system using a GUI program.  Rather than logging into a system and then manually starting X, X comes up after boot and is ready to go.  While XDM (or GDM for GNOME or KDM for KDE) is not necessary on server systems, any system where X Windows is used on a regular basis benefits from XDM.  And XDM is easy to set up too.  With FreeBSD, one can simply build and install from the ports collections:

cd /usr/ports/x11/xdm
make install clean

Now one just needs to modify /etc/ttys to enable XDM. The XDM entry is already in this file, it is just disabled on the default install. To enable XDM after installing it, change “off” to “on” between the xterm and secure parameters.

ttyv8 "/usr/local/bin/xdm -nodaemon" xterm on secure"

Unlike GDM or KDM, XDM does not allow one to select a window manager. The window manager should be executed from a .xsession script in your home directory. I setup my system so that .xsession is a symlink to a .xinitrc file (read by startx when manually starting X11) in my home directory. If you need XDM and startx to have different startup methods, then you must provide separate files with customization for each program.

Without a .xsession file, XDM and startx default to /usr/X11R6/lib/X11/xinit/xinitrc. With my default install of FreeBSD, at the bottom of the script, the window manager twm is started, along with three xterms which are opened by default.

I cannot stand twm, so next I will look at setting up a different light-weight window manager. As my experience with Ubuntu and GNOME on this machine proved, I don’t have the memory on this machine for desktop environments like GNOME or KDE.

nVidia graphics driver on FreeBSD 8.2

First of all, find the proper driver for your device.  I used nVidia’s driver download page to get the right version: 96.43.20.  My card is an nVidia GeForce4 MX 420, and it is not supported on higher version number drivers that support more modern video cards.

Download the driver tarball with your web brower or wget and unarchive it.

cd /root
tar -xzf NVIDIA-FreeBSD-x86-96.43.20
cd  /root/NVIDIA-FreeBSD-x86-96.43.20
vi doc/README

As you can see in the documentation, you just need to do a ‘make install’.  Before doing so, however, comment out lines 25 through 36 as this check will prevent you from being able to build the driver.  (I don’t know why this check was in here…perhaps on more modern drivers this is not necessary)

/*
#if __FreeBSD_version >= 800000
#error This driver does not support FreeBSD 8.x/-CURRENT!
#endif
#if __FreeBSD_version >= 700000 && __FreeBSD_version < 700055 #error This driver does not support FreeBSD 7.x/-CURRENT! #endif #if __FreeBSD_version >= 600000 && __FreeBSD_version < 600034
#error This driver does not support FreeBSD 6.x/-CURRENT!
#endif
#if __FreeBSD_version < 503000
#error This driver requires FreeBSD 5.3 or later!
#endif
*/

Build and install the driver:

make install

If the driver builds with no errors, the driver kernel module should be installed in /boot/modules.  To test the driver and make sure that everything works,

I used the nvidia-xconfig tool to create a basic xorg.conf file. The tool automatically detected my video card and setup the correct information in the Device section.

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "NV17 [GeForce4 MX 420]"
    BusID          "PCI:1:0:0"
EndSection

The tool also added additional required modules by the driver.

Section "Module"
	Load  "dbe"
	Load  "dri"
	Load  "dri2"
	Load  "extmod"
	Load  "glx"
	Load  "record"
EndSection

I then had to customize the monitor settings. I have a wide-screen monitor that I like to run at 1920×1200. I tried explicitly setting this in the Modes subsection of the Screen section, but was unable to get the setting to work (though 1024×768 worked with no problems). Apparently, X is smart enough these days to figure out the max resolution on its own, so I simply commented out the Modes subsection.

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
#        Modes      "1920x1200" "1024x768" "800x600" "640x480"
    EndSubSection
EndSection

I setup the Monitor section with more descriptive names as well as putting in the exact horizontal sync rate and vertical refresh rate from the instruction manual for my Samsung display.

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Samsung"
    ModelName      "Syncmaster P2250"
    HorizSync       30.0 - 81.0
    VertRefresh     56.0 - 60.0
    Option         "DPMS"
EndSection

To test the configuration, use the -config option on the X program, passing it the customized X configuration.

X -config /root/xorg.nvidia.conf

Once satisfied with the settings, I copied the config file to /etc/X11/xorg.conf and tried to start X Windows.

cp /root/xorg.nvidia.conf /etc/X11/xorg.conf
startx   # ugly tvm should start

Finally, with the driver working, it can be added to load automatically during boot, allowing the use of graphical log-in programs such as XDM.  To load the driver during the boot stage, add the following to /boot/loader.conf:

nvidia_load="YES"

Next I shall look at configuring XDM so that I don’t have to always manually start X.

Routes to hosts on the local network

On my private LAN, I have a number of hosts, but the two most important are my FreeBSD box–named so creatively as “bsd”–and “trantor“, my MacBook.  Typing the IP address of “bsd” when I want to access it gets old fast, and there is an easy way to be able to access it by name.  On my MacBook, I just have to add the following to /private/etc/hosts:

192.168.1.107      bsd

On my FreeBSD box, edit /etc/hosts and add:

192.168.1.105      trantor

Before hitting my ISP’s DNS server, the hosts file is consulted and used to obtain the IP address of the host on my private LAN.

FreeBSD wireless config for Ralink NICs

Before getting started, I just wanted to share my configuration.

FreeBSD: FreeBSD 8.2 RELEASE
Wireless AP: 802.11 a/b/g using WPA Personal (TKIP)
Default Gateway: 192.168.1.1
DHCP server: 192.168.1.100

The adapter can be identified by looking in the messages during the boot phase, which are logged to /var/run/dmesg.boot.  I have a D-Link PCI wireless NIC, and the chipset is by Ralink, and thus uses the ral0 driver.  I also found my Ethernet NIC card too, which I am not using at the moment.

ral0: Ralink Tech RT2561S …. irq 5 dev 15 pci0
vr0: VIA VT3043 Rhine I 10BaseT/100BaseTX …. irq 9 dev16 pci0

Being able to see ral0 during the boot process means that the kernel has recognized the hardware and loaded the driver.  You can verify this with ifconfig:

ifconfig ral0

You should see the entry in here, and the  status should be ‘no carrier’.  Your wireless NIC is now recognized by the kernel, but before trying to bring it up, there is further configuration required.

For WPA, wpa_supplicant handles the encryption, where we must provide the SSID of the access point as well as the access point passphrase, which gets encrypted as a PSK.  Since I am using WPA Personal, I need to use wpa_passphrase to generate a config file that I can provide to the wpa_supplicant module with the proper SSID and PSK.  The file should be stored as /etc/wpa_supplicant.conf.

wpa_passphrase [ssid] [passphrase] > /root/wpa.conf      # keep a backup
cp  /root/wpa.conf /etc/wap_supplicant.conf

With the security out of the way, we only have to configure the wlan module.  It would appear that in the past you could try to bring up the interface via the driver name, but the 802.11 system has changed and you now must create a wlanX device for use with ifconfig rather than the actual device itself.  This is not as hard as it sounds.  Add the following to your /etc/rc.conf file.

# /etc/rc.conf
….
wlan_ral0=wlan0
ifconfig_wlan0=”WPA DHCP”            # use WPA crypto and DHCP

The device ral0 is now mapped to wlan0 through the wlan module, and ifconfig is told that wlan0 expects WPA crypto and should use DHCP to obtain an IP address for the interface wlan0.  At this point I rebooted, and after the login prompt appeared I logged in as root and checked on the wlan0 interface.

ifconfig wlan0

Now the status should say ‘associated’ rather than ‘no carrier’, and you should have an IP address as well.  Try to connect to an outside source to verify the wireless link is working:

ping www.google.com

And that is all there is to it, much easier than I thought!

Returning to FreeBSD

I have an old PC that I bought in 1999 just before entering college.  It came with Windows NT 4.0 and after my first semester I ended up installing FreeBSD in a separate disk partition and dual-booting (of course these days one would just use a VM).  My university taught FreeBSD rather than Linux in the computer science courses, and we were running FreeBSD 3.x.  At the time there was little support for my nVidia Riva TNT graphics card, so I mostly used FreeBSD for school work and learning UNIX.

After finishing school I did not take the machine with me overseas, so it mostly sat in storage.  I’ve been using laptops at home since then, and I hadn’t really given the machine much though.  However, thirteen years later, this machine is still solid.  All of the original parts work, minus the CD-RW drive.  I had to replace one in 2002, and the replacement drive is no longer working well.  The Iomega Zip drive still works perfectly (no click of death yet!), and with 256 MB of RAM and a that old graphics card it runs Windows 2000 like a champ.  I can even get 1900×1200 on my LCD monitor.

The problem is I don’t have much of use for Windows.  I only use ModelSim, which is overkill on this old machine, so I usually run Windows in VirtualBox on my MacBook.  So what to do with this old PC then?  I have wanted to get into Linux kernel mode programming, so I thought I would install Linux on the machine.  My workstation at my job runs Ubuntu 11 which I quite enjoy.  So what not start there?

Ubuntu 11.04 – easy config and setup, but you need memory

I downloaded the Ubuntu CD ISO and tried to install it on the old PC.  The installer would fail after booting the live CD, and after searching on the Internet, I found that 256 MB of RAM was not enough to run the graphical installer.  I downloaded the text-code Ubuntu CD and then proceeded to install it.  The install went smoothly and everything seemed well.  Everything was installed and I was able to connect to my wireless network with ease.  However, when I tried to launch the terminal, it took nearly 20 seconds for the terminal to appear.  I tried opening Firefox, and it took nearly a minute to load.  Clearly I still did not have enough memory to run Ubuntu.  I really like the debian package management system though, I hate battling ‘yum’, ‘zypper’, and the rpm management tools on the servers at work.  So perhaps I’ll just try Debian?

Debian 6 – Lightweight, but be prepared to spend days getting it to work

I have never tried Debian before.  In the past at least, it had a reputation for being difficult to configure and use.  To my surprise though, the install process was quite smooth.  Perhaps I just know what is going on now that I’ve been working with UNIX for a few years at work?  I logged into the gnome on my newly installed Debian box only to find that there was no way to setup wireless networking.  I only had disk 1, and the geniuses at Debian decided that disk 4 would have network-manager, disk 5 would have gnome-network-manager, and disk 2 would have many of the dependencies for both of those packages.  I eventually installed all of the packages manually with dpkg, and even when I had the gnome-network-manager installed and usable, I still could not connect to my wireless network.  I put that aside and tried to install nVidia’s legacy driver for my graphics card.

No go.  On this minimalist Debian system, even binutils were not installed by the Debian installer!  Luckily binutils were on disk 1, but even after installing them, the nVidia installer would not run.  I became fed up and gave up on Debian.  Debian was light-weight enough to run on this machine, but with packages spread over 30+ CDs and no connection to my wireless network, I decided to try to move on.  Well, there’s always Fedora Core, right?

Fedora Core – memory, memory, memory

I considered Fedora Core as it was the distro that I had used in the past quite a bit.  A quick look at the Fedora webpage and I had already given up–I needed at least 768 MB of RAM, three times what i had in this machine.

Longing for Solaris and SPARC

At this point I was longing for my Sun Blade 150 that I owned while living in Tokyo.  It was an old machine too, and Ultrasparc III with just 512 MB of RAM and a DVD-ROM drive.  However, that machine was slick.  Installing Solaris 10 was a breeze, and everything just worked out of the box.  As with Apple products, when the hardware and software are controlled by one company, things just work…at a price though!  I thought briefly about the idea of Solaris x86, but quickly decided that was not a good idea.

Back to FreeBSD

So it was back to FreeBSD after  many years away from it.  I downloaded the single CD for the install, and though slightly simplified, the install screen looks just as it did back in the year 2000 when I first installed FreeBSD on this same machine.  Back in 2000, the machine had a powered by Windows NT sticker which I covered up with a FreeBSD sticker.  How ironic that this same machine was running FreeBSD again.  I installed the kernel developer base, and running have a very learn machine with no GUI yet, but wireless networking, vim 7, and gcc 4.6, all installed over the wire.  FreeBSD just works.

Conclusions

I really just need to buy a modern PC.  I still want to muck around with the Linux kernel, but I don’t want to spend days configuring the machine with no network connection.  I have built embedded computer systems, bringing up these systems from nothing, writing the firmware for the processors and FPGAs, and making them fully functional products.  Yet I have never built my own PC from parts…perhaps it is time for me to give that a try?  Somehow that seems more daunting to me than building systems with microcontrollers and FPGAs.  It shouldn’t be though, I just have to carefully select the parts.  So the Linux kernel stuff can wait until I have figured my PC build.

With this old PC, I will let it run FreeBSD happily.  I’ve never custom complied my own FreeBSD kernel, and that is one of the projects I have planned.  Perhaps I can try to run my own DNS server so that I can connect to my MacBook by CNAME rather than IP address?  I’m sure more ideas will come out over the coming days.

Fixing a botched /etc/rc.conf file

In an effort to get my wireless NIC working, I added a line to /etc/rc.conf and decided to reboot the system. On start-up, however, the system reported a syntax error and presented me with the option to fix it.

/usr was not mounted, so I was unable to edit the file with vi. I tried using /bin/ed to edit the file, but the system reported that the system was read-only. I was not sure what to do, but luckily the FreeBSD team has splendid documentation and FAQs.

As the FAQ states, one has to mount the root file system as read/write in order to modify any of the files. I rebooted and when presented with the syntax error, escaped to the shell. I then proceeded to mount the root file system with write access:

mount -urw /
mount -a -t ufs    # for vi

After making the changes, I did a quick reboot and sure enough the problem was fixed.

A Haskell development platform…almost

The Haskell Platform is really a great addition to the Haskell community. It adds a lot of common libraries and tools all at once, such as the Haskell package manager cabal. I suppose you could install each package as you need it, but in the Haskell world everyone loves cabal and darcs and you might as well get them all at once.  (note: I don’t think the Platform includes darcs).  Saves you time anyways.  Cabal is great for grabbing other Haskell libraries, and I suppose it is analogous to  Ruby gems or Python eggs.

I’m running OS X 10.5.8–yes, I know I need to upgrade–and thus I had to get Haskell Platform 2010.2.0.0 rather than the latest version.  OS X is still the third leg in the world of operating systems, however.  At work I have a Linux workstation, and for the most part everything just works, except for the occasional problem with amd64/x86_64 platform.  Trying to use anything not specifically designed for Mac is always an exercise in troubleshooting.  But I wouldn’t give up OS X as my main desktop system.

The platform installer is straight forward–a DMG image–and you just install the Glasgow Haskell Compiler, and then the Haskell Platform. Unfortunately, the Haskell Platform is not entirely perfect…

> cabal --help
dyld: unknown required load command 0x80000022
Trace/BPT trap

Yikes, dynamic linker errors! But a Google search turned up a solution to install cabal from the sources and ignore the cabal from the Platform. After downloading the tarball:

zcat cabal-install-0.10.2.tar.gz | tar xf -
cd cabal-install-0.10.2
chmod u+x bootstrap.sh
./bootstrap.sh

The script uses GHC to build cabal, and then installs it to ~/.cabal. Make sure to add ~/.cabal/bin to your PATH variable. We should also blow away the borked cabal.

sudo rm /usr/local/bin/cabal
sudo rm /usr/bin/cabal
sudo ln -s /Users/.cabal/bin /usr/local/bin/cabal

I tried running cabal again, and this time there were no dyld errors. I had wanted cabal so I could install the gtk2hs bindings that allow Haskell programs to create GTK+ GUIs. I was also hoping I wouldn’t have to be a GTK2+ guru or systems guru to install such a package.  Unfortunately, things did not really work out, and after checking the gtk2hs web page, installing for OS X is not as easy as a simple cabal command.  The dreaded MacPorts would be required…

First we must install GTK, and this does take awhile.  I thought I had installed GTK+ before, because I run EiffelStudio through Apple’s X11 implementation.  (EiffelStudio required MacPorts too, by the way).  Might as well try to install it though, just in case EiffelStudio was statically linked to the GTK libraries…or maybe it does not even use GTK+, thought it sure looks like it…

sudo port selfupdate
sudo port install gtk2 +universal
sudo port install cairo
sudo port install pango

It took forever to install gtk2.  It must have installed very library under the universe.  GTK+ has always made me crazy, it is dependent on so many libraries.  You might as well install all of a Linux distro onto your Mac for GTK+. Motif, while ugly these days, was so much nicer to work with.  So then I tried to install the gtk package with cabal, following the gtk2hs installation guide:

cabal install gtk2hs-buildtools
cabal install gtk --ghc-option="-DCABAL_VERSION_MINOR=10"

Unfortunately it fails when trying to reconcile the gio package.

Configuring gio-0.12.0...
Preprocessing library gio-0.12.0...
Building gio-0.12.0...
[ 1 of 24] Compiling System.GIO.Signals ( dist/build/System/GIO/Signals.hs, dist/build/System/GIO/Signals.o )
[ 2 of 24] Compiling System.GIO.Types ( dist/build/System/GIO/Types.hs, dist/build/System/GIO/Types.o )
[ 3 of 24] Compiling System.GIO.Enums ( dist/build/System/GIO/Enums.hs, dist/build/System/GIO/Enums.o )
[ 4 of 24] Compiling System.GIO.File.FileAttribute ( dist/build/System/GIO/File/FileAttribute.hs, dist/build/System/GIO/File/FileAttribute.o )
[ 5 of 24] Compiling System.GIO.Volumes.VolumeMonitor ( dist/build/System/GIO/Volumes/VolumeMonitor.hs, dist/build/System/GIO/Volumes/VolumeMonitor.o )

System/GIO/Volumes/VolumeMonitor.chs:56:4:
    Not in scope: `vmDriveStopButton'
cabal: Error: some packages failed to install:
cairo-0.12.0 failed during the building phase. The exception was:
ExitFailure 1
gio-0.12.0 failed during the building phase. The exception was:
ExitFailure 1
gtk-0.12.0 depends on gio-0.12.0 which failed to install.
pango-0.12.0 depends on cairo-0.12.0 which failed to install.

I don’t know that I want to spend anymore time on this.  And GUIs are overrated anyways.  I like to try different programming languages and technologies, but still I fall back to C++.  For this GUI app (a CAD app, thus it needs a GUI), I’ll just stick to C++ and Qt 4.  I suppose I always revert to C++ because I understand the errors and the tools, and I can quickly fix any problems I encounter.

At least I have GHC, cabal, and darcs installed,  I can at least do console programming with Haskell. I’m hooked on Erlang, but I still want to explore more with Haskell, if not for anything but learning more concepts.

I’m sure that Apple doesn’t make it any easier on the maintainers of the Haskell Platform with their ever-changing tools.  Apple is always quick to change things and break dependencies too.  Nonetheless, give the Haskell Platform a change.  I suspect if you’re on a Linux box it all just works, especially a Debian/Ubuntu system where apt-get will quickly take care of your prerequisites and dependencies.

I’ve got more interesting projects to work on, such as my ZigBee project.  I’d rather spend my time there then messing with GTK.

News from my desk

So summer is about gone and here I am wondering where the first half of the year has gone.  Autumn is my favorite season though and I’m looking forward to the next few months.  Work is busy and not particularly too interesting.  I’m developing some scheduling software at the very bottom of the MAC layer to interface with the PHY in a next-generation wireless communications system based on WiMAX technology.  The technology will enter trials in Q2 2009 in Japan and we’ll see if it can deliver the data rates we’re hoping for.  Sadly, I suspect this technology will stay here in Japan.  I doubt that Taiwan, Thailand or China will implement this new mobile network with LTE just around the corner as well. They do have the existing PHS infrastructures though, so I won’t bet on anything just yet.

This is my first time to work on MAC layer software.  Until now I’ve worked mainly around the PHY layer.  The MAC layer is not an interesting subject in itself–just a lot of packet formatting and error checking and redundancy.  To all you software people out there, never let the hardware people talk down to you.  Their hardware systems are useless without software in our modern digital communication era.  Don’t get a big head either though, without their hardware improving data rates, we’d still be writing dialers and dealing with TDD access schemes in a wireless medium.

Change of subject, here is a picture of my workstation setup at home.  Please remember I’m in Tokyo and have little space in my tiny apartment for a nicer work area.  C’est la vie.  I dream of a big oak desk with enough room for a desktop workstation and plenty of room to write on paper!

My home workspace

My home workspace

My primary computer is the MacBook on the right.  I use it for e-mail, web browsing, pictures and normal life things.  I also use it to play around with programming stuff related too C++ or Obj-C.  I have some ideas for OS X software, I just have to make the time for them!

On the left is a Sun Blade 100 system, a 64-bit Ultrasparc IIe system I have been using to get a better grasp on the Solaris OS.  Last year I was kind of burnt-out with regard to writing software.  I was thinking of following a SysAdmin track, so I bought the Blade 100 used and studied Solaris.  While I’m not going to become a SysAdmin and I’m going to stick with software, I’m glad I took the time to study Solaris.  The services administration system, svcs, is a wonderful improvement to the UNIX world and I think I would be grumpy if I had to work on Solaris 9 or other UNIX systems that still require scripting to manage services.  I wouldn’t be grumpy actually, I’d just be telling myself how I missed Solaris 10 service administration.  Solaris Zones and ZFS are also really impressive, but I only have a 20 GB disk in the machine and that doesn’t leave me a lot of room to play around.  Currently, I primarily use the machine to fool around with C++ or Erlang these days.  Though Solaris isn’t such a rather poor choice for desktop use, I would happily put it on servers and let it run my software.

I was first introduced to Solaris when I was in college.  The computer engineering department did everything on Windows because we did a lot of FPGA and embedded systems work and the academic versions of the tools only ran on Windows.  I doubt the grad students running the lab had the ability to administer a Linux network either!  I digress.  Our software engineering courses were offered by the computer science department, and all of our assignments had to run on UNIX for grading.  Some people could not stand UNX, but I became attracted to it just because the UNIX lab was always empty and quiet.  Most people would go to the Windows lab, code and test in Visual C++, and then do final testing and submission via via telnet to the UNIX lab machines.  The Windows lab was noisy due to people cranking up their portable CD players (this was before the iPod, folks!) or talking to each other or running large print jobs.  The UNIX lab was always silent and I was able to really focus on my work.   Since then I guess I have developed a soft spot for Solaris and UNIX in general.  It feels the most natural to run g++ and which up some makefiles.  Maybe this is why I like Windows driver development?  When I entered the professional world, getting used to configuring IDEs was a bit of an annoyance.  But that went away fast and now I don’t really care–either way as long as I can build my system and not fight the tools all of the time.   OK, enough nostalgia!

It seems, however, that Solaris is finally good enough for generic x86 systems, so when I move back to the US or move to Taiwan (just a dream!),  I’ll retire the Blade 100 workstation and buy an AMD or Intel workstation so I can run multiple operating systems.  I know Solaris isn’t the zippiest OS, but it has earned my trust over the years and I think that if I had an AMD system with enough memory I probably wouldn’t notice.  After all, anything is an improvement over the Blade 100!

Boost 1.36 and Sun Studio 12

Trying to get Boost and Sun Studio C++ compilers to place nice on Ultrasparc processors isn’t exactly straight-forward.  I fought with both Sun CC and g++, and after browsing mailing lists of Boost and other C++ software, reading various blogs at Sun, and through brute force effort, I managed to build Boost 1.36 for Sun CC.  I just have to add that it was a lot easier getting Boost to build on Mac OS X with g++!  I’m sure someone will say it I’m and idiot since I couldn’t get it to work ont he first try, but let me just say that it was not obvious.  I did a lot of reading and still did not come away with a definitive answer.  The guys at Sun ought to create a Wiki for both Sun Studio users and Sun engineers to share information on working with Boost.

Before I get into the build process, here is the build environment I used just for reference:

# uname -a
SunOS radium 5.10 Generic_137111-02 sun4u sparc SUNW,Sun-Blade-100

# CC -V
CC: Sun C++ 5.9 SunOS_sparc Patch 124863-06 2008/07/08

Of course it is always a good idead to make sure your Sun Studio patches are up-to-date before you start.  The build process I used is listed below.

1. Build a custom version of Bjam for your machine.  Download it from Boost’s sourceforge portal and follow the install directions.  It builds painlessly and installs itself in /usr/bin by default.

2. After downloading and unarchiving Boost 1.36 to a stating platform–I used /opt–change your working directory to the Boost root directory and run the configuration script.  Run ./configure –help to see the various options.  I used the following to specify the location of bjam, the compiler to use, and finally where to put everything in the end:

./configure –with-bjam=/usr/bin/bjam –with-toolset=sun –prefix=/opt

It is important to specify the compiler if you have both g++ and Sun CC in your path environment variable.  On a default developer’s install of Solaris 10, you have g++ in /usr/sfw/bin and then if you installed Sun Studio 12, a symlink is placed in /usr/bin that points to CC.  Be careful!

3. Configure your user-config.jam file which is used by Bjam when building Boost.  After running the configure script, my user-config.jam looked like this:

# Boost.Build Configuration
# Automatically generated by Boost configure

# Compiler configuration
using sun ;

# Python configuration
using python : 2.4 : /usr ;

I added some flags for the compiler to fix a lot of the error messages I was getting when I would run the make process.  The modified file looks like this:

# Boost.Build Configuration
# Automatically generated by Boost configure

# Compiler configuration
using sun : 5.9 : /opt/SUNWspro/bin/CC : <stdlib>sun-stlport <link-flags>-library=stlport4 <cxxflags>-native64 ;

# Python configuration
using python : 2.4 : /usr ;

I should add that I don’t know if this is necessary based on step four in my process.  I really did not feel like trying to hack around the build process as it is complicated and honestly, I want to work on my application, not on becoming a guru Boost builder.  I made this changes because it is suggested on many of the mailing list troubelshooting messages.

4.  Finally, run Bjam to build your application.  On the Boost homepage it says you can run “make install”, but I found whenever I did this the build process would fail to compile any of the libraries.  I explicity invoked the Bjam tool as follows:

bjam toolset=sun stdlib=sun-stlport instruction-set=v9 address-model=64 install

This command may be redundant based on the parameters in user-config.jam, but I just wanted to be sure.  I turned off the monitor and went to bed because it takes a long time to build software on a Sun Blade 100!  Before leaving for work the next morning I checked a log file that I dumbed all of the build process output to and this time I had no errors.  The libraries were put in /opt/lib and my headers in /opt/include.  All is well that ends well.  Now it is time to put Sun’s compiler and tools to work!

Follow

Get every new post delivered to your Inbox.