Using starlib - how to compile in your code.

Currently, starlib does not install itself into any standard system library directories, although you are certainly free to do so if you chose, and have root access, by copying libstar.a into /usr/local/lib and copying the header files into /usr/local/include.) The most likely way that this first version of starlib will be used is on only one or two programs, and not installed into the general Unix library heirarchy. These instructions will assume that this is how you are using starlib.

After running the instructions in the the install page, you will have a collection of *.h files and a single libstar.a file, and several *.o files, one of which is called template.o. Once the compile is finished, you can delete all the *.o files, except for the one called template.o - that one is needed for linking with programs that use starlib.

In general, to make use of starlib in your program, you must include the "ast.h" file from this starlib directory. It will weave its way through all the other header files such that you should only need to include "ast.h" in your code.

In general, when compiling an executable using starlib, you must remember to add "-lstar -ll" to the end of the final link command. (The -ll is needed to make the star file parser work. It brings in a library used by the "lex" routines.) Also, you need to link in the template.o file with your final link. The reason for linking the template.o file is that the method used by the compiler to resolve C++ template instantiations on SGI fails to notice the templates when they are contained in a library .a file. Other compilers might not have this problem, and if you are using this on a different compiler, the inclusion of template.o on the final link might not be needed.

To implement the above, assuming you are using a Makefile in your project, and that you made the files in a directory called "starlib", make these changes yo your Makefile: Add these lines near the top:

Insert this change to every compile statement in your Makefile: If it used to say something like this:

make it say this instead:
On the other hand, If it used to say something like this:

make it say this instead:

These instructions are crude, but they get you the idea. They give you a solution that is not clean, but works. You can of course make your Makefile nicer once you understand what the above instructions are doing.

Go on to the next topic, how to write your main program to make use of starlib.


- previous topic - - next topic -