> henry wrote:
> 
> Dear List:
>     I have 2 sub-libraries(image.c ,gif.c ) used by a libraries
> generic.c
> How could I link them as a static library libgeneric.a ,
> Could someone shed some light?
> 
> 
> gcc -c image.c -o image.o
> ar rcs  libimage.a image.o
> 
> gcc -c gif.c -o gif.o
> ar rcs  libgif.a gif.o
> 
> gcc -c generic.c -o generic.o -L. -limage -lgif  <-   it seems that I
> do wrong on this line
> ar rcs libgeneric.a generic.o


I'm not really sure what you're trying to do. If your trying to build a
file called libgeneric.a that contains the object files from image.c,
gif.c and generic.c, you just need to do this:

        gcc -c image.c -o image.o
        gcc -c gif.c -o gif.o
        gcc -c generic.c -o generic.o
        ar rcs libgeneric.a image.o gif.o generic.o

You only use -L/-l when you're linking an executable. Creating a static
library (.a file) is not the same as linking -- all building a static
library does is archive your object files together.


Matthew
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to