Link Archiver: Difference between revisions

m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(2 intermediate revisions by 2 users not shown)
Line 1:
{{Stub}}
GNU '''ar''' is a utility that archives a series of files. It is used to take a group of files, and combine them all into one. This allows one to then compress, send, or most importantly and commonly, link the files into a program.
{{Infobox_Tool
|name=GNU Archiver
|website=http://www.gnu.org/software/binutils/
}}
 
GNU '''ar''' is a utility that archives a series of files and is part of the [[binutils]] package. It is used to take a group of files, and combine them all into one. This allows one to then compress, send, or most importantly and commonly, link the files into a program.
==Usage==
 
== Usage ==
The tool itself is about as simple as its purpose. To archive a series of object files:
<sourcesyntaxhighlight lang="bash">ar -rcs archive.a obj_fil1.o obj_fil2.o obj_fil3.o obj_fil4.o ... obj_filN.o</sourcesyntaxhighlight>
 
Then, to link against them:
<sourcesyntaxhighlight lang="bash">cc example.c archive.a -o example.bin</sourcesyntaxhighlight>
 
'''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.
 
== See Also ==
 
===External Links===
=== Articles ===
*[http://www.gnu.org/software/binutils/manual/html_chapter/binutils_1.html GNU 'ar' online manual].
* [[binutils]]
* [[LD|ld]]
 
=== External Links ===
* [httphttps://www.gnusourceware.org/software/binutils/manualdocs/html_chapterbinutils/binutils_1ar.html#ar GNU 'ar' online manual].
 
[[Category:LinkersBinutils]]