Software Porting Tips
for OpenStep for Mach
by Rex Dieter
Wed Oct 28 10:52:44 CST 1998

-------

This is taking a lot longer than expected.  After a lot of reserching and contemplation, it turned out that everything here is just one big 'ol FAQ, and not much really like an article.  Besides, I've been having way too much fun playing with Rhapsody DR's to have any free time anyway... (-;

CHANGELOG

Oct 28, 1998
* Continue work on this once dead project.
* Drop use/mention/support of NEXTSTEP 3.x and focus on OpenStep for Mach 4.2 only, with only fleeting references to Rhapsody/MacOS X Server 1.0
* Drop a hint to -static flag hack to build NEXTSTEP 3.3 compatible binaries (another article?)
* Drop a hint to -posix flag hack to restore the POSIX compatibility library madness.(another article?)

------

There are a lot of tricks of the trade that one can utilize to get your favority UNIX utility to build successfully for OpenStep for Mach.  I'll present this more as a FAQ, with sections detailing some of the more common issues that arrise when porting Unix-level, Terminal-based (not OpenStep GUI) software.

I'll assume that readers have at least a casual knowledge of how compilers work.  I'll also attempt to include at least a few concrete examples of their usage.  As a matter of fact, I'll even do some of the work for you and include the source-code (and binary) to some handy files and functions that are missing from OpenStep's C Library.

C Issues

1.  When compiling, the compiler complains with the error:

(include exact error message here).

This occurs because OpenStep's cc compiler uses a customized preprocessor that takes advantage of pre-compiled system headers (for performance, primarily).  This customized preprocessor isn't fully compatible, however, with some legacy C source code.  To disable the customized preprocessor and use the (more or less) standard gcc one, add the following command-line option to the c compiler:  -traditional-cpp

POSIX

1.  What is POSIX?

IEEE 1003.1 (aka POSIX, aka POSIX.1) is the modern standard of essential  system calls, and is/was intended to unify the system call API's between SysV and BSD unix.  However, POSIX is intended to define a portable operating system environment that can be provided under non-Unix operating systems, such as NT and the like.

 -- quoted from a USENET post by Charles Swiger.

2.  I want/need POSIX-compliant library functions, what do I do?

a.  Don't use them, NeXT's posix library (support for which has been discontinued as of OpenStep 4.2) is pretty broken.  

b.  Besides, the libposix.a library links statically, so your resulting binary will be significantly larger.  See (a), really.  Explore other options, you'll thank yourself later.  

c.  If you want to try to use the posix library, add the flag -posix to the compiler (and linker) command-line options.  Support for the -posix flag was dropped as of OpenStep for Mach 4.2.  (I have a hack to restore it, but it's not pretty).

d.  A footnote: Rhapsody, who's UNIX layer has been updated to use BSD4.4, includes most (if not all) POSIX library functions that are available to other POSIX-compliant systems (like Solaris and  Linux)

Missing Library functions

	basename
	getcwd
 	mmap / munmap
	putenv / setenv
	strdup
 	waitpid
	tempnam/tempname (from glibc)
	termios functions

C++ Issues (I need to re-write this section significantly)

1.  I want to build a C++ program, but OpenStep's cc  (or cc++) compiler chokes.
2.  I want to use the GNU libg++ C++ library.

I've ported the gcc compiers, which includes support for C, C++ (including libg++) and Fortran.

gcc (2.7.2.3) for NEXTSTEP 3.x to supports following platforms:
m68k-next-nextstep3	(includes i386-next-nextstep3 cross-compiler)
i386-next-nextstep3	(includes m68k-next-nextstep3 cross-compiler)

Find these at peak, http://www.peak.org/next/apps/devtools/

gcc (v2.7.2.3) for OpenStep for Mach 4.x supports the following platforms (built on and tested only on OpenStep for Mach 4.2):
i386-next-nextstep4
(ns3-drivers)		m68k-next-nextstep3, i386-next-nextstep3 cross-compilers

Find these at peak, http://www.peak.org/openstep/apps/devtools/

Fortan Issues

1.  I want a Fortan compiler.

See C++ Issues.

Linking/Using External Libraries

Discuss