参考资料: 1.ICCAVR IDE 中的在线帮助中的Librarian: A library is a collection of object files in a special form that the linker understands. When a library's component object file is referenced by your program directly or indirectly, the linker pulls out the library code and links it to your program. The standard supplied library is libcavr.a, which contains the standard C and AVR specific functions. Other libraries, such as libstudio.a, override some functions in libcavr.a so that a different behavior can be achieved without changing your program code. For example, by linking in libstudio.a, your program may use the Terminal IO window under AVR Studio. Of course, the linking process is mostly transparent to you - by choosing the appropriate Compiler Options, the IDE generates the correct switches to the compiler programs. Nevertheless, there are times where you need to modify or create libraries. A command line tool called ilibw.exe is provided for this purpose (note: the PROFESSIONAL version may include capabilities that handle library files within the IDE, please inquire for details). Note that a library file must have the .a extension. See Linker Operations. Compiling a File into a Library Module Each library module is simply an object file. Therefore, to create a library module, you need to compile a source file into an object file. This can be done by opening the file into the IDE, and invoking the File->Compile File To Object command. Listing the Contents of a Library On a command prompt window, change the directory to where the library is, and give the command "ilibw -t ". For example, ilibw -t libcavr.a Adding or Replacing a Module 1. Compile the source file into an object module. 2. Copy the library into the work directory 3. Use the command "ilibw -a " to add or replace a module. For example, the following replaces the putchar function in libcavr.a with your version. cd \icc\libsrc.avr copy \icc\lib\libcavr.a ; copy library ilibw -a libcavr.a iochar.o copy libcavr.a \icc\lib ; copy back ilibw creates the library file if it does not exist, so to create a new library, just give ilibw a new library file name. Deleting a Module The command switch -d deletes a module from the library. For example, the following deletes iochar.o from the libcavr.a library: cd \icc\libsrc.avr copy \icc\lib\libcavr.a ; copy library ilibw -d libcavr.a iochar.o ; delete copy libcavr.a \icc\lib ; copy back 2.ICCAVR IDE 中的在线帮助中的Compiler Options: Target的Additional Libraries项介绍: Additional Libraries - You may use other libraries besides the standard ones provided by the product. For example, on our website is a library called libstk.a for accessing STK-200 peripherals. To use other libraries, copy the files to the library directory and specify the names of the library files without the "lib" prefix and the ".a" extension in this box. For example, "stk" refers to the libstk.a library file. All library files must end with the .a extension.