Mail Archives: djgpp/1997/09/27/12:45:05
At 02:24 9/26/1997 -0700, WiZKiD wrote:
>Hi Everyone,
>
>I'm having problems triend to develop my own library. I have a couple
>of function and would like to group them all up and distribute this
>library file in a file like "stuff.lib", and have a C program call it
>up as #include "stuff.h". I know that I have to make a header-file
>with the prototype for each function and all. But I don't know how to
>go about compiling the functions into a library :o(
Okay, here's what you do. You compile all the source files for your functions:
gcc -c [-whatever] func1.c
gcc -c [-whatever] func2.c
...
Then you use `ar' to make them into a library.
ar qc libfoo.a func1.o func2.o ...
Finally you use `ranlib' to add the dictionary to the library.
ranlib libfoo.a
Note that you can do the same thing with the `s' flag to `ar'; see its docs.
To use your library, #include your header file in the source file, and when
linking, add `libfoo.a' to the list of files. Alternatively you can copy it
to your lib directory, and link with the option `-lfoo'.
>Any help would be apreciated. Ok, thanks for reading this long
>request. Have a great day.
Long?!? You haven't been reading this ng long :) That's a really short
posting compared to many I see here. A quite reasonable length.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -