Newsgroups: comp.os.minix
Subject: Re: c++ on minix
References: <7j7mv4$a39$3@news.inet.tele.dk>
Organization: Syracuse University, Syracuse
From: mcconnel@hydra.syr.edu (Terry R. McConnell)
NNTP-Posting-Host: hydra.syr.edu
Message-ID: <3757cebf.0@news.syr.edu>
Date: 4 Jun 1999 09:03:59 -0500
X-Trace: 4 Jun 1999 09:03:59 -0500, hydra.syr.edu
Lines: 38
Path: star.cs.vu.nl!newsfeed.amsterdam.nl.net!sun4nl!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.syr.edu!hydra.syr.edu!mcconnel
Xref: star.cs.vu.nl comp.os.minix:35757

In article <7j7mv4$a39$3@news.inet.tele.dk>,
Stephan Dragehjerte <7879@e.aarhus.ih.dk> wrote:
>
>If I compile a program on my linux (intel pentium 166) and
>disable optimisasion and only use 286instructions (if that
>is possible at all?) and link the program statically, would
>it then run on my minix (PS/2-30 = 286 intel) ?
>

No. There are many problems with this. First off, the object file produced
by your linux compiler needs to be linked with a "run-time" module, usually
called something like crt.o and kept in a place like /usr/lib. The run-time
module does some setup - e.g, it makes command line arguments available to
your code through argc and argv - before branching to your program's entry
point. Unfortunately, these run-time modules are highly OS dependent. Moreover,
you can't get around this by trying to link a minix crt.o with a linux foo.o.
The linux linker won't understand the minix object file format and vice-versa.

A second problem is that even the simplest programs  make calls to library
functions. The lowly "hello world" program already uses printf, e.g. Library
routines are ultimately just an API to the underlying OS system calls and
these are definitely incompatible across systems.

Finally, you have the problem that the executable (linker output) formats
are different.

With a bit of skill you could get around the first problem by writing your
own Minix compatible crt.c and compiling it under Linux. Getting around the
second problem would require rewriting large portions of the library. It 
would probably be simpler to rewrite your C++ app in C and compile it with
the native minix compiler. Or better, port g++ to minix and make it 
available to everybody.  

-- 
************************************************************************
Terry R. McConnell   Mathematics/304B Carnegie/Syracuse, N.Y. 13244-1150
trmcconn@syr.edu                            http://barnyard.syr.edu/~tmc 
************************************************************************
