Using static library

Andrea 'fwyzard' Bocci
Tue Dec 10 08:30:00 GMT 2002

At 19.26 09/12/2002 +0100, Wojtek DHAS wrote:
>I have probably very easy question. I have some static windows library

Curious. I thought windows libraries were .lib files.

>  and I would like to use some function from it. How to call function
>from static lib ?

Le's say you need to link agains libfile.a :
1.) Put the library in the linekr search path (see gcc / binutils manual 
for this)
2.) #include the relevant "file.h" in your sources
3.) link with the library passing "-lfile" (the same name as the library 
minus the initial "lib") to gcc.

Eg., to link against libiberty.a:
1.) have libiberty.a installed somewhere
2.) #include "libiberty.h"
3.) link with "gcc mfiles.o -liberty -o executable_name"

HTH, fwyzard 

More information about the Gcc-help mailing list