summaryrefslogtreecommitdiff
path: root/reference/C/LIBRARIES/libraries.html
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2008-01-27 11:37:44 +0100
committerTobias Klauser <tklauser@xenon.tklauser.home>2008-01-27 11:37:44 +0100
commit7e0f021a9aec35fd8e6725e87e3313b101d26f5e (patch)
treeb1cacc4b24393f517aeb4610e9e1021f954307a8 /reference/C/LIBRARIES/libraries.html
Initial import (2.0.2-6)2.0.2-6
Diffstat (limited to 'reference/C/LIBRARIES/libraries.html')
-rw-r--r--reference/C/LIBRARIES/libraries.html107
1 files changed, 107 insertions, 0 deletions
diff --git a/reference/C/LIBRARIES/libraries.html b/reference/C/LIBRARIES/libraries.html
new file mode 100644
index 0000000..bdc66fc
--- /dev/null
+++ b/reference/C/LIBRARIES/libraries.html
@@ -0,0 +1,107 @@
+<html>
+<head>
+<title>User created libraries/archives</title>
+<script language="JavaScript">
+</script>
+</head>
+
+<body bgcolor="#ffffcc">
+<hr>
+<center>
+<h1>User created libraries/archives</h1>
+</center>
+<hr>
+<p>
+
+Wot is a user library? I hear you ask! Well, its a collection of your
+functions, that, when placed into a library are available to all the programs
+you write.<p>
+This is what
+<a href="../CONTRIB/SAWTELL/c-lesson.7">Chris Sawtell</a>
+has to say about libraries.
+<p>
+There are two types of library, <a href="dynamic.htm">dynamic</a>
+and static. Although dynamic libraries
+are the prefered alternative (because they are not linked
+into your program), here is the method required to create
+static libraries....
+<p>
+There are several steps required in creating a library.<p>
+<ul>
+<li>Create a function.
+<li>Create an object module of the function.
+<li>Add the object module to the library/archive.
+<li>Compile a program that uses the library/archive.
+</ul>
+<hr>
+Here are the four steps in UNIX terms. The function is called <b>reverse</b>
+and the library is called <b>mart</b>.
+<p>
+<center>
+<table border=2 bgcolor=ivory>
+<tr><td>
+<pre>
+
+ vi reverse.c # write your function (no main).
+ gcc -c reverse.c # -c just compiles (no link).
+ ar -q libmart.a reverse.o # -r == if nessasary replace
+ # an existing function.
+ gcc program.c -lmart -L/home/leslim # -l == library to search
+ # -L == Location of the library.
+</pre>
+</td></tr>
+</table>
+</center>
+<p>
+
+A few notes:<p>
+<ul>
+<li>reverse.c should NOT contain a <b>main</b>.
+<li>A header file containing the prototype for reverse.c is required.
+<li>I expected to be able to add /home/leslim to LD_LIBRARY_PATH but
+gcc does not seem to look at this variable for its list of libraries.
+<li>If you dont want to use the <b>-L</B> option you will have to place
+your library in a directory like <b>/usr/lib</b>.
+<li>DONT LOOSE THE SOURCE! You cant rebuild the source from the object
+module. If you want to make a change at a later date you will want
+the source.
+</ul>
+<hr>
+Other usefull commands:
+<ul>
+<li>ar -t libmart.a == List the Objects in a library.
+</ul>
+<p>
+<hr>
+<h2>See Also:</h2>
+<ul>
+<li><a href="syscalls.htm">System calls and Library calls.</a>
+</ul>
+
+
+
+<p>
+
+<hr>
+<p>
+<center>
+<table border=2 width="80%" bgcolor="ivory">
+<tr align=center>
+<td width="25%">
+<a href="../cref.html"> Top</a>
+</td><td width="25%">
+<a href="../master_index.html"> Master Index</a>
+</td><td width="25%">
+<a href="../SYNTAX/keywords.html"> Keywords</a>
+</td><td width="25%">
+<a href="../FUNCTIONS/funcref.htm"> Functions</a>
+</td>
+</tr>
+</table>
+</center>
+<p>
+<hr>
+<address>Martin Leslie
+</address><p>
+</body>
+</html>