(This weekly column looks at features and products that revolve around Mac OS X, Apple’s next generation operating system that’s due in early 2001. If you aren’t familiar with terms like “Rhapsody” and “OpenStep,” check out our explanatory “Note” at the end of this article before proceeding.)
This week we’re looking at the UNIX aspects of Mac OS X — specifically the ability to run UNIX executable programs under Mac OS X — in the first of a three-part series. This information is based on my conversation with others as, admittedly, UNIX is not an area of expertise for me. As I try to point out on occasion, this column is written by an advanced end user (Yours Truly), not a programmer or developer. However, the folks quoted in this article do fall into these categories or otherwise have extensive UNIX experience.
Tim Bedford said that Mac OS X’s standard installation comes with almost all the tools you’d expect to find in a UNIX distribution, the majority of which are command line utilities that can be accessed via the Terminal application. Apple has written Mac OS X interfaces to some command line apps, such as the Process Viewer (underneath the interface, it’s just the UNIX top command).
“Apple didn’t supply the development tools as standard with Mac OS X Public Beta,” Bedford told MacCentral. “Although strange for a UNIX distribution, given what Apples core market is, this isn’t surprising. Apple also had the good sense to make the tools freely available to download from the Internet for those that wanted them.”
Most UNIX apps come in source code form and can be freely compiled; this is why a C compiler is a standard part of UNIXes, he added. Most command line apps will compile and run will little or no modification.
“However, it is worth noting that my Mac OS X installation is on a UFS partition and not HFS+,” Bedford said. “Knowing full well that I would try to run UNIX applications and wanted to maximize the chances of them working, I chose the UNIX native disk format, as a result of this, Classic has never worked even though it resides on its own HFS+ partition. So I have to dual boot. Code changes I have had to make are with networking implementation, and these only very minor. The sound of this may scare the average Mac user but UNIX users have a different culture. For any UNIX-savvy Mac user, this doesn’t pose a significant problem.”
When discussing Mac OS X running UNIX apps, he said that most people are probably referring to X Windows. The X Windows system provides the base for the graphical user interface of UNIXes. Apple’s next generation operating system may have UNIX at the core and may have X in its title, but it’s not X Windows. No X Windows application will run directly on Mac OS X, Bedford said. But there is hope and an interim solution.
The X Window server, XFree86, has been ported to Mac OS X and will allow the use of X applications — at a price, he said. XFree86 can’t run at the same time as Quartz. Instead you have to logout and log back into the console (enter “>console” as your user name at the login window), Bedford said. Now you have a command line only interface through which you can launch XFree86, then your X Windows applications.
“In the future one would hope for a secondary window server to be created for Mac OS X that maps X Windows calls to Quartz and in so doing would allow X Windows applications to run along side Mac OS X ones,” he added. “The X windows applications would then also take on the Aqua appearance.”
In the UNIX world applications are normally distributed as source code; once they’re compiled, they will generally only run on that particular combination of UNIX distribution and hardware configuration. This means it’s possible that a binary executable will only work not just on machines using the same distribution, but on the specific machine it was compiled on, Bedford said. So will a Linux executable run on Mac OS X? No.
“But again there are ways to overcome this,” Bedford explained. “Sun Microsystems have already done so with a utility called ‘lxrun,’ which allows users of Solaris x86 to run Linux applications. This maps any libraries a Linux application requires to the appropriate Solaris ones and also translates its signals to Solaris ones so that the Linux application will run. This is not the same as emulation and only incurs a ~5 percent processor overhead.”
Even better news is that lxrun is open source and Solaris is also BSD derived. Chances that lxrun can be ported to Mac OS X are high, Bedford said.
“Given time I believe that Mac OS X users will be sitting and looking smug as they run the latest cool Cocoa Mac OS X applications along side X windows ones,” he added. “Nothing will come close, and the mere thought has me grinning.”
Josh Aas said he’s one of a “rare breed”: a long-time UNIX programmer on a Mac. But he said an Apple system with a telnet/SSH connection can actually get just as much or more done than someone who has to deal with UNIX production on a “less than pro” graphical user interface (GUI). Aas has tested many programs under OS X. For programs not having to do with HTTP, TCP/IP, and other networking functions, he said he has have never had a failure — with the exception of KDE/Gnome apps, and XFree86 KDE and Gnome environments themselves.
“In short: non-network-related command line apps work great,” he added. “UNIX/Linux GUI apps are buggy if you can get them to work at all. (Mac OS X’s GUI does not like giving up control). The reason for network related apps being buggy is that Mac OS X does not use the standard UNIX networking structure (inetd or Network Daemon). Instead, Mac OS X has replaced these services with NetInfo (from NeXT), which UNIX apps don’t understand.”
Interestingly, many of the standard UNIX tools are there (inetd and friends), but they serve no purpose other than sucking up CPU cycles, Aas said. Interacting with them doesn’t override NetInfo, so they’re effectively useless, he added.
“An example is trying to access the localhost account from the local copy of Apache in a Web browser,” Aas said. “If you have a dialup connection, you cannot even access the HTTP from your own machine unless you have and active TCP/IP connection (you are dialed up). Very odd, but I’m sure it will be fixed up in the final version.”
Also, the cc (Apple’s version of UNIX gcc, the compiler) works great, he added. It compiles just fine and the install scripts for UNIX apps recognize it 99 percent of the time, according to Aas.
“I have had no problems with the standard UNIX routine of ‘sh configure,’ ‘make,’ ‘make install.’ Now let’s see if Apple can work in the RedHat Packet Manager (RPM),” he added.
Next week: part II.
(Note: Mac OS X is the upcoming, “next generation” operating system from Apple, due in the first half of 2001. Mac OS X will include components of the traditional Mac OS, as well as components of the Rhapsody project. Rhapsody was once planned as Apple’s next generation operating system. It’s still around as Mac OS X Server, and parts of Rhapsody technologies will become part of Mac OS X. Rhapsody/Mac OS X Server is partially based on OpenStep technologies that Apple obtained in the purchase of the NeXT company. Carbon is the modified version of the Mac OS application programming interfaces (APIs) that lets applications be rewritten with relative ease for Mac OS X.)