Although sanos applications are normally compiled under Windows you can also compile your applications under sanos using the sanos system development kit (SDK).
The sanos SDK consists the following components:
I've made a virtual disk image (.vmdk) with the the sanos SDK. The image contains a bootable copy of sanos, the C compiler, assembler, development utilities, source files, runtime library, and some sample programs. The SDK also has a copy of the QEMU PC emulator. You can boot the image by running the runsanos.cmd script. You can also run this under Linux if you install the QEMU PC emulator:
sudo apt-get install qemu qemu sanos.vmdk -net user -net nic,model=virtio
If you want to try the C compiler go to the /usr/src/utils/samples directory and compile the hello sample program:
/$ cd /usr/src/utils/samples /usr/src/utils/samples$ cat hello.c #include <stdio.h> int main(int argc, char *argv[]) { printf("hello world\n"); return 0; } /usr/src/utils/samples$ cc hello.c /usr/src/utils/samples$ ./hello hello world /usr/src/utils/samples$ _
The source files for the SDK are included in the
source release of sanos.
You can build the disk image with the SDK using the nmake sdkdisk
command.
This will make a virtual disk image in \sanos\win\img\sanos.vmdk
.
The Makefile first builds sanos, including some additional development utilities (ar, make, and impdef). Next, the assembler (as.exe) and C compiler (cc.exe) are built using the Visual Studio C compiler.
The libc.lib
file in \sanos\win\lib
is the sanos C runtime
library for building sanos programs using the Microsoft C compiler. It is in COFF LIB format.
This library cannot be used by the Tiny C compiler. The Tiny C compiler uses ELF object (.o) and
archive (.a) files like the GNU compiler (gcc). In order to compile programs under
sanos we need to build a C runtime library that can be used with TCC. To do this, we
use the Tiny C compiler compiled for sanos (cc.exe
). This can be run under
Windows because of the special version of os.dll
placed in the \sanos\sdk\bin
directory. This is the sanos-on-windows edition of os.dll
. This is an implementation
of the sanos API running under win32.
You can also build the C compiler, assembler, make, ar, impdef, and the C runtime library
under sanos. The /usr/src
directory contains a Makefile
for
rebuilding the tools and the runtime library while running sanos:
/$ cd /usr/src /usr/src$ make sdk ... /usr/src$ make install-sdk ...
usage: cc [-v] [-c] [-o outfile] [-Bdir] [-bench] [-Idir] [-Dsym[=val]] [-Usym] [-Wwarn] [-g] [-Ldir] [-llib] [-shared] [-soname name] [-static] [infile1 infile2...] General options: -v display current version, increase verbosity -c compile only - generate an object file -o outfile set output filename -B dir set tcc internal library path -bench output compilation statistics -fflag set or reset (with 'no-' prefix) 'flag' (see man page) -Wwarning set or reset (with 'no-' prefix) 'warning' (see man page) -w disable all warnings -g generate runtime debug info Preprocessor options: -E preprocess only -Idir add include path 'dir' -Dsym[=val] define 'sym' with value 'val' -Usym undefine 'sym' Linker options: -Ldir add library path 'dir' -llib link with dynamic or static library 'lib' -shared generate a shared library -soname set name for shared library to be used at runtime -entry sym set start symbol name -fixed addr set base address (and do not generate relocation info) -filealign n alignment for sections in PE file -stub file set DOS stub for PE file -def file generate import definition file for shared library -static static linking -rdynamic export all global symbols to dynamic linker -r generate (relocatable) object file -m mapfile generate linker map file