You can use Microsoft Visual C to build native applications for sanos. The
native API for sanos is a POSIX like interface, including a BSD socket interface.
Look in the API reference or in
src\include\os.h for a list of all the native sanos API calls. Sanos
also includes an implementation of the ANSI standard C runtime library.
If you want to build native application for sanos under sanos you can use the sanos system development kit (SDK).
The following is a guide to building a simple hello world application for sanos. This example assumes you are using Visual Studio version 7. To build the hello world application you first need to create a new project. You can either use the sanos project wizard or configure the project manually.
If you want to use the wizard you need to copy the following files from \sanos\vcwizard to the C:\Program Files\Microsoft Visual Studio .NET\Vc7\vcprojects directory:
If your sanos files are not located in c:\sanos you need to modify the ABSOLUTE_PATH parameter in sanoswiz.vsz. To use the wizard select File->New->Project in Visual Studio:

Select 'Sanos Project', choose name (e.g. hello) and location for project, and click 'OK'.

Choose the application type and change the Sanos SDK path to point to your location for the sanos SDK. Selecting the 'Create floppy disk boot image' option adds an image project to the solution that can build a boot floppy configured for the application. Clink 'Finish' to create a project configured for sanos. Now you are ready to start programming. Insert the following code for the hello world program:
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("hello world\n");
return 0;
}Select the Release configuration (in Build->Configuration Manager) and build
the application. Now you should have a hello.exe file in your
project release directory. If you build the image project in the solution you
get a hello.flp boot image file in the release directory. Copy this
image to a floppy disk using the mkfloppy tool and boot the computer from the
floppy. After booting sanos the hello program executes.
If you want to try a slightly more realistic sample application for sanos you can take a look at the webserver demo application.
You can also compile sanos programs from the command line. After running vsvars32.bat you can compile the hello.c program using the compiler from the command line:
cl -X -I\sanos\src\include hello.c /link os.lib libc.lib /LIBPATH:\sanos\lib /FIXED:NO
The -X option makes the compiler ignore the standard include paths and the -I option ensures that you use the sanos include files instead. The program is linked with os.lib (the sanos os api library) and libc.lib (sanos C runtime library). The /FIXED:NO is needed to make sure that hello.exe has relocation information.
You can compile C programs for sanos under sanos by using the sanos system development kit (SDK). If you want to compile the hello world sample using the SDK you can use the following command in the sanos shell:
\usr\src$ cc hello.c \use\src$ ./hello
If you want to create the project manually you must first create a new empty project:
hello and click 'OK'. This starts the
Win32 application Wizard.Now you have created a new blank project. The project is configured for Win32 projects so we need to change some project properties to compile for sanos:
c:\sanos\src\include;$(NOINHERIT). This disables all
standard include directories and uses the sanos include files instead.c:\sanos\lib;$(NOINHERIT). This disables all
standard include directories and uses the sanos library directory instead.os.lib libc.lib $(NOINHERIT) and 'Ignore All Default Libraries'
to Yes. This will link the application with the
sanos API defined in os.lib and the C runtime library in libc.lib.
The libc library also contains the startup code for the application./FIXED:NO. By default the compiler does not generate relocation information for EXE applications,
only for DLL's. This requires that the application can be loaded at the compiled base address (default 0x400000).
This is not always possible in sanos because it uses a single process design. Setting the /FIXED:NO
linker option forces the linker to always generate relocation information to allow the application to be loaded at any address.The project is now configured for sanos applications. Add the hello.c file to the project and follow the procedure described above to build the application.