4.5.18 How Do I Create My Own Libraries?
To use one or more library files that were built by yourself or a colleague, include them in the list of files being compiled on the command line. The library files can be specified in any position in the file list, relative to the source files. However, if there is more than one library file, they will be searched in the order specified in the command line.
An example of specifying the library liblibrary.a
on the command line is:
xc-dsc-gcc -mcpu=33FJ256GP710 -T
p33FJ256GP710.gld main.c int.c liblibrary.a
If you want to use the -l
option, then:
xc-dsc-gcc -mcpu=33FJ256GP710 -T
p33FJ256GP710.gld main.c int.c -llibrary
If you are using MPLAB X IDE to build a project, add the library file(s) to the Libraries folder that is in your project, and in the order in which they should be searched. The IDE will ensure that they are passed to the compiler at the appropriate point in the build sequence. For information on how you build your own library files, refer to the 6.3.1 Library Files section.