> i was just wondering how to create and add my own library on the system.
> it is something like this... i have some basic function calls etc which as
> of now are in one source file called mylib.c . whenever i write a program
> ie. test.c
> which uses the functions from the file mylib.c ,
> i first create a object file
> $ cc -c mylib.c
> then i compile test.c like this ,
> $ cc -o test test.c mylib.o
>
> what i would like to know is if there is a way to put the library mylib.c
> into the /usr/lib/ directory where other libraries reside. then anyone
> hooked to my computer could just specify something like
> $ cc -o test test.c -lmy
>
> i know there is something like "ar" which might help to achieve the above.
> but then that's it. i couldn't find the man pages of much help.
Yes, ar will do that. You want to use the create (c) option. I'm not
certain wheter ar can create shared libraries or only static libraries.
If you want to make shared libraries, gcc/g++ (note on Linux machines,
cc is usually a link to gcc) seems to do it (I use an Imakefile and
specify a shared library so I don't have to mess with the details).
Here is what happens when I compile some code into a library using an
Imakefile:
g++ -g -O2 -fPIC -Wformat -Wreturn-type -Wunused -c Image.C
-I. -I/home/dreed/include -I/home/dreed/pub/include
-I/usr/openwin/include -I/home/dreed/pub/Mesa/include
-I/home/dreed/pub/JPEG/include
rm -f libimage++.so.1~
+ cd .
+ g++ -o ./libimage++.so.1~ -shared -Wl,-soname,libimage++.so Image.o
+ rm -f libimage++.so
+ ln -s libimage++.so.1 libimage++.so
+ true
rm -f libimage++.so.1
mv -f libimage++.so.1~ libimage++.so.1
rm -f libimage++.so
ln -s libimage++.so.1 libimage++.so
-Dave
[EMAIL PROTECTED]
--
PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject.