ChorusOS 4.0 Production Guide

Creating a Simple Hello Application

Create a subdirectory, src, within your MYCOMP directory.

To create a simple hello application,

  1. create the following three files in the MYCOMP/src directory:

    • hello.c, this source file will say hello and is written as follows:

      #include <stdio.h>
          extern void bye();
          main()
          {
              printf("Hello\n");
          #ifdef BYE
              bye();
          #endif
              exit(0);
          }
      

    • hello.bf, this file provides rules to build the application and contains the following information:

       C__SRCS = hello.c
          LIBS = $(OS_DIR)/lib/classix/libcx.a $(NUCLEUS_DIR)/lib/classix/libsys.s.a
          Actor(hello, $(LIBS))
          Export(hello, $(MYCOMP_DIR)/root/bin)
      

      The hello.bf file declares:

      • The source files to be compiled.

      • The libraries to be used.

      • The fact that you want to build the hello actor.

      • The fact that you want to copy the hello actor into the root/bin directory, once it is built.

    • hello.df, this file defines the variables and contains the following information:

          ../../Paths
          VARIABLES="OS_DIR NUCLEUS_DIR"
          BDIR=${BUILD_DIR}
          INCLUDES="-I${OS_DIR}/include -I${NUCLEUS_DIR}/include \
          -I${OS_DIR}/include/chorus -I${NUCLEUS_DIR}/include/chorus"
      

      The hello.df file contains two parts. The first three lines give the location of the various components that MYCOMP depends on. The INCLUDES variable shows where to look for header files.

  2. Build your component in your work directory using the make command:

    host% make
    
  3. Add the hello binary file to the target file system, using the following command:

    host% make root