Link Archiver: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
formatting changes |
m →Usage |
||
Line 3: | Line 3: | ||
==Usage== |
==Usage== |
||
The tool itself is about as simple as its purpose. To archive a series of object files: |
The tool itself is about as simple as its purpose. To archive a series of object files: |
||
< |
<source lang="bash">ar -rcs archive.a obj_fil1.o obj_fil2.o obj_fil3.o obj_fil4.o ... obj_filN.o</source> |
||
Then, to link against them: |
Then, to link against them: |
||
< |
<source lang="bash">cc example.c archive.a -o example.bin</source> |
||
'''Important''': If you link other object files besides the library ''archive.a'', take care that the ''archive.a'' is right behind these object files (or have it be the very last file in the list of files to link) - so the linker can resolve the one or other occurrence of a symbol which is covered by some member of the ''archive.a'' library. |
'''Important''': If you link other object files besides the library ''archive.a'', take care that the ''archive.a'' is right behind these object files (or have it be the very last file in the list of files to link) - so the linker can resolve the one or other occurrence of a symbol which is covered by some member of the ''archive.a'' library. |