next up previous contents index
Next: 3.1.5 Using sdcclib to Up: 3.1 Compiling Previous: 3.1.3 Projects with Multiple   Contents   Index


3.1.4 Projects with Additional Libraries

Some reusable routines may be compiled into a library, see the documentation for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc) for how to create a .lib library file. Libraries created in this manner can be included in the command line. Make sure you include the -L <library-path> option to tell the linker where to look for these files if they are not in the current directory. Here is an example, assuming you have the source file foomain.c and a library foolib.lib in the directory mylib (if that is not the same as your current project):

sdcc foomain.c foolib.lib -L mylib

Note here that mylib must be an absolute path name.

The most efficient way to use libraries is to keep separate modules in separate source files. The lib file now should name all the modules.rel files. For an example see the standard library file libsdcc.lib in the directory <installdir>/share/lib/small.


next up previous contents index
Next: 3.1.5 Using sdcclib to Up: 3.1 Compiling Previous: 3.1.3 Projects with Multiple   Contents   Index
2008-12-05