|
From: Tim R. <tim...@ic...> - 2002-07-27 13:16:37
|
> What I want to know is, how would I compile things for the Mobius? (Bear
> in mind I want to know what I type on the command line, like 'gcc
> hello.c -o hello.o -I./include' or what have you.) It'd be appreciated
> if someone could tell me the exact thing which I'd need to do :) After
> that, I'll (hopefully) be able to work it out for myself.
So far I've compiled and linked everything separately; linking via gcc
(rather than ld) might pull in some non-Mobius libraries, although I'm not
sure.
Something like this should be enough:
gcc -c hello.o -o hello.o -I/mn/include
ld -o hello.exe hello.o /mn/src/crt0.o /mn/lib/libc.lib
/mn/lib/libsys.lib
That will link hello.o with the C startup code and the DLL versions of the C
library (libc) and the Mobius library (libsys). For every user-mode library
you get the choice of linking statically (i.e. linking in the functions you
use within the EXE) or dynamically (i.e. linking to the DLL). You're
probably better off linking with the DLL for everything; otherwise, you end
up duplicating code in the EXE.
All the header files you'll need are in the include directory in the Mobius
source tree (probably /mn/include). The standard C headers are in the
include directory itself; the Mobius ones are in include/os, and the POSIX
ones are in include/posix.
As you may have seen from the makefiles in the CVS, builds for most things
are automated. That is, you can do this to build an EXE with the default
options:
TARGET= $(BIN)/hello.exe
OBJS= hello.o ../crt0.o
LIBS= $(LIB)/libc.lib $(LIB)/libsys.lib
include ../make.conf
include ../make.actions
crt0.o assumes you're using int main(int argc, char **argv) (or int
main(void) ).
wcrt0.o assumes you're using int wmain(int argc, wchar_t **argv) (or int
wmain(void) ).
To build a library, use TARGET_D=name.dll and/or TARGET_S=name.lib (DLL and
static) instead of TARGET.
Any more questions, feel free to ask. In the meantime, I'll see if I can
improve the build process so that it works for everyone -- I think removing
libsys's dependency on libc should make things smoother.
|