Libraries: 6 Compiler Directives

Up: GEOS SDK TechDocs | Up | Prev: 5 Header Files

Libraries have to be compiled slightly differently from applications. Since library routines are run under application threads, they must treat global variables differently than applications do. You must therefore add pragmas to ensure that the library is compiled correctly.

There are several steps to take:

Most compiler manuals have a section on compiling dynamically-linked libraries (DLLs) for Microsoft Windows; this section will describe how to set up these conditions. Note that you need only do this if your library will have its own global or static variables. If the library's routines and methods use only local, automatic variables, you need not perform these actions.

When you compile a library, you must pass the argument "-L <libname>" to Goc. Edit your local.mk file to make it insert this flag. For more information about the local.mk file, see Using Tools chapter.

Finally, if your library is written in C or Goc (or if its API is in C, even if some internal routines are written in assembly), you must indicate this by putting the flag c-api on the "type" line of the library's .gp file. This instructs the kernel to pass arguments on the stack (instead of in registers) when calling the entry point routine.


Up: GEOS SDK TechDocs | Up | Prev: 5 Header Files