Compiling and linking scheduler user code

To compile and link user code for the Scheduler, Microsoft Visual C++ Version 6.0 SP3 or later (version 8.02 or earlier) or Microsoft Visual Studio 2010 (version 8.03) is required. If you did not install Microsoft Visual C++ (version 8.02 or earlier) or Microsoft Visual Studio (version 8.03) with the option to set up for use from a command prompt, your PATH, LIB, and INCLUDE environment variables may not be set correctly. To set these, you can run VCVARS32.BAT, which is located in the \bin subdirectory of your Visual C++ (version 8.02 or earlier) or Visual Studio (version 8.03) installation.

The following steps will guide you in the procedures used to compile and link your user code:

  1. Create your database directory and copy the files MAKEFILE and USER.DEF from the USERCODE directory into it. For example:
    $ cd USERCODE
    $ mkdir mydb
    $ cd mydb
    $ copy ..\MAKEFILE .
    $ copy ..\USER.DEF .
  2. Edit the MAKEFILE and change the “OBJFILES” line, which is near the top of the file, to list your .C user code files. Instead of a .C file extension, you must use a .OBJ file extension when specifying the files. Case does not matter. In most cases, you will not need to change anything else in this file. However, there are additional variables you can use for custom compile or link options or for additional libraries to be linked into the program. For example, the files FILE1.C, FILE2.C, and FILE3.C would be specified as:
    OBJFILES = file1.obj file2.obj file3.obj
  3. If your user code calls functions uccschd0 or uccsched you must perfor m this step. Otherwise, you can skip to step 4. When scheduling user events, one of the steps is to add function declaration lines to the .DEF file that is used by the linker. See the documentation on function uccsched in Section 3.3 for more details. Instead of copying and editing the APS_SUSR.DEF file as documented there, you must make your edits to the USER.DEF file that you copied in step 1. Go to the end of the USER.DEF file and add a line consisting of the name of the user-written event function. The case should match the case of the name as it appears in the .C file. Repeat for each user-written event function.
  4. You can now perform the compile and link by running the NMAKE command. At an MSDOS command prompt, change directory to the database directory and run the NMAKE command. This command reads the file MAKEFILE and follows the directives in it to compile and link your user code. Be sure to correct any compile or link errors before proceeding. For example:
    $ cd USERCODE\mydb$ nmake
  5. You can now run the Scheduler and it will use your user code. Any time you change your user code, you must repeat the appropriate steps in this process.