paulw 发表于 2008-2-18 16:52:20

请问马老师,使用icc编译器,是否可以编译打包封装的C代码,也就是说别人看不到的库文件或

使用icc编译器,是否可以编译打包封装的C代码,也就是说别人看不到的库文件或者其他格式文件。我感觉可以,因为icc官方的好多库函数是看不到源代码的,但对于自己应用不知如何操作,请马老师指点一二,谢谢!!!

machao 发表于 2008-2-18 19:21:15

参考ICC的HELP

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 <library>". 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 <library> <module>" to add or replace a module.

For example, the following replaces the putchar function in libcavr.a with your version.

cd \icc\libsrc.avr

<modify putchar() in iochar.c>

<compile iochar.c into iochar.o>

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

paulw 发表于 2008-3-12 09:17:45

最近一直忙单位的项目,没来的急上来,谢谢马老师!

Oliver 发表于 2008-3-12 09:29:33

趁早用IAR吧.库管理相当完善.堪称完美

paulw 发表于 2008-3-13 11:28:53

是吗??哪天试试
页: [1]
查看完整版本: 请问马老师,使用icc编译器,是否可以编译打包封装的C代码,也就是说别人看不到的库文件或