summaryrefslogtreecommitdiff
path: root/how_to_archive_with_posix_ar.html
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-07-26 17:18:50 +0200
committerAki <please@ignore.pl>2021-07-26 17:21:00 +0200
commitbfa4c0d559c43d83d2d07014e7b765a287a0c944 (patch)
tree48e9f2095077b8efcda753928d46efd0139f39e1 /how_to_archive_with_posix_ar.html
parent84cf03cc1e12236924063973b4cf86193b5e7287 (diff)
downloadignore.pl-bfa4c0d559c43d83d2d07014e7b765a287a0c944.zip
ignore.pl-bfa4c0d559c43d83d2d07014e7b765a287a0c944.tar.gz
ignore.pl-bfa4c0d559c43d83d2d07014e7b765a287a0c944.tar.bz2
Fixed type and extended usage section of ar
Diffstat (limited to 'how_to_archive_with_posix_ar.html')
-rw-r--r--how_to_archive_with_posix_ar.html20
1 files changed, 15 insertions, 5 deletions
diff --git a/how_to_archive_with_posix_ar.html b/how_to_archive_with_posix_ar.html
index b4dce3b..77dd77c 100644
--- a/how_to_archive_with_posix_ar.html
+++ b/how_to_archive_with_posix_ar.html
@@ -13,14 +13,15 @@
<article>
<h1>How To Archive With POSIX ar</h1>
-<p class="subtitle">Published on 2021-07-26 00:47:00+02:00
+<p class="subtitle">Published on 2021-07-26 00:47:00+02:00, last modified on 2021-07-26 17:09:00+02:00
<p>Let's continue <a href="how_to_archive_with_posix_tar_cpio_and_pax.html">last POSIX archiving guide</a> from the
very spot we finished. Today, we'll deal with just one tool. Very peculiar one, because it's more of a development
utility than an archiver with portable format. In fact, it doesn't have a defined format at all. More than that, POSIX
-acknowledges that several incompatible formats are known and that they don't care.
+acknowledges that several incompatible formats are known and that they don't care. User can usually count on one
+implementation to support archives created on another machine using the same implementation, so it's not that bad.
<p>It's time to stop pretending that <a href="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ar.html">ar</a>
-does not exists and learn how to use it.
+does not exist and learn how to use it.
<p>Now then, when exactly do we want to use <b>ar</b>? Luckily, that's simple to answer. <b>ar</b> is used to create
libraries of object files that are meant to be later linked against. In other words, it creates <i>static libraries</i>.
@@ -69,13 +70,22 @@ your friendly manual or standard itself.</p>
<img src="how_to_archive_with_posix_ar-1.png" alt="palm tree">
<p>You probably won't need to extract files from the archive, simply because you put it together so that the linker uses
-it and not yourself. Still, you can extract files from it in two ways. First one is <code>-x</code> option:
+it and not yourself, usually in a variation of one of the following ways. All depending on what tool is used as linker
+and if the archive is available to it through its search paths:
+
+<pre>
+$ cc -l:archive.a main.o -o main
+$ ld main.o archive.a -o main
+</pre>
+
+<p>Still, if you need to extract files, you can extract them from library in two ways. First one uses <code>-x</code>
+option:
<pre>
$ ar -x archive.a
</pre>
-<p>This simply extract all of the files from the archive directly into current directory. Keep in mind that the paths
+<p>This simply extracts all of the files from the archive directly into current directory. Keep in mind that the paths
are not remembered, only the basenames are. Using those basenames you can also extract selected files from the archive:
<pre>