MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip
MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip
MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Using the <strong>Compiler</strong> on the Comm<strong>and</strong> Line<br />
3.5.9 Options <strong>for</strong> Linking<br />
If any of the options -c, -S or -E are used, the linker is not run <strong>and</strong> object file names<br />
should not be used as arguments.<br />
TABLE 3-13: LINKING OPTIONS<br />
Option Definition<br />
-Ldir Add directory dir to the list of directories to be searched <strong>for</strong> libraries<br />
specified by the comm<strong>and</strong>-line option -l.<br />
-llibrary Search the library named library when linking.<br />
The linker searches a st<strong>and</strong>ard list of directories <strong>for</strong> the library, which is<br />
actually a file named liblibrary.a. The linker then uses this file as if<br />
it had been specified precisely by name.<br />
It makes a difference where in the comm<strong>and</strong> you write this option; the<br />
linker processes libraries <strong>and</strong> object files in the order they are specified.<br />
Thus, foo.o -lz bar.o searches library z after file foo.o but be<strong>for</strong>e<br />
bar.o. If bar.o refers to functions in libz.a, those functions may not<br />
be loaded.<br />
The directories searched include several st<strong>and</strong>ard system directories,<br />
plus any that you specify with -L.<br />
Normally the files found this way are library files (archive files whose<br />
members are object files). The linker h<strong>and</strong>les an archive file by scanning<br />
through it <strong>for</strong> members which define symbols that have so far been<br />
referenced but not defined. But if the file that is found is an ordinary<br />
object file, it is linked in the usual fashion. The only difference between<br />
using an -l option (e.g., -lmylib) <strong>and</strong> specifying a file name (e.g.,<br />
libmylib.a) is that -l searches several directories, as specified.<br />
By default the linker is directed to search:<br />
\lib<br />
<strong>for</strong> libraries specified with the -l option. For a compiler installed into the<br />
default location, this would be:<br />
c:\Program Files\<strong>Microchip</strong>\<strong>MPLAB</strong> C30\lib<br />
This behavior can be overridden using the environment variables<br />
defined in Section 3.6 “Environment Variables”.<br />
-nodefaultlibs Do not use the st<strong>and</strong>ard system libraries when linking. Only the libraries<br />
you specify will be passed to the linker. The compiler may generate calls<br />
to memcmp, memset <strong>and</strong> memcpy. These entries are usually resolved by<br />
entries in the st<strong>and</strong>ard compiler libraries. These entry points should be<br />
supplied through some other mechanism when this option is specified.<br />
-nostdlib Do not use the st<strong>and</strong>ard system startup files or libraries when linking. No<br />
startup files <strong>and</strong> only the libraries you specify will be passed to the<br />
linker. The compiler may generate calls to memcmp, memset <strong>and</strong><br />
memcpy. These entries are usually resolved by entries in st<strong>and</strong>ard<br />
compiler libraries. These entry points should be supplied through some<br />
other mechanism when this option is specified.<br />
-s Remove all symbol table <strong>and</strong> relocation in<strong>for</strong>mation from the<br />
executable.<br />
-u symbol Pretend symbol is undefined to <strong>for</strong>ce linking of library modules to<br />
define the symbol. It is legitimate to use -u multiple times with different<br />
symbols to <strong>for</strong>ce loading of additional library modules.<br />
-Wl,option Pass option as an option to the linker. If option contains commas, it<br />
is split into multiple options at the commas.<br />
-Xlinker option Pass option as an option to the linker. You can use this to supply<br />
system-specific linker options that the compiler does not know how to<br />
recognize.<br />
© 2008 <strong>Microchip</strong> Technology Inc. DS51284H-page 55