18.2 Using Library Routines
Library functions or routines (and any associated variables) will be automatically linked into a program once they have been referenced in your source code. The use of a function from one library file will not include any other functions from that library. Only used library functions will be linked into the program output and consume memory.
/pic32m/include/) in your project properties. The xc32-gcc
compilation driver automatically selects the XC libc and their respective include-file
directory for you; similarly, the xc32-g++ compilation driver automatically
select the C++ library respective include-file directory. Manually adding a system include
file path may disrupt this mechanism and cause the incorrect libc include files to be compiled
into your project, causing a conflict between the include files and the library. Note that
adding a system include path to your project properties has never been a recommended practice. Your program will require declarations for any functions or symbols used from libraries. These are contained in the standard C header (.h) files. Header files are not library files and the two files types should not be confused. Library files contain precompiled code, typically functions and variable definitions; the header files provide declarations (as opposed to definitions) for functions, variables and types in the library files, as well as other preprocessor macros.
#include <math.h> // declare function prototype for sqrt
int main(void) {
double i;
// sqrt referenced; sqrt will be linked in from library file
i = sqrt(23.5);
}MPLAB® Harmony includes a set of peripheral libraries, drivers, and system services that are readily accessible for application development. For access to the plib.h (peripheral header files), go to the Harmony web site (www.microchip.com/mplab/mplab-harmony) to download MPLAB Harmony.
