Re: [ILUG] Linux's DLL's

From: John P. Looney (john at domain antefacto.com)
Date: Thu 31 May 2001 - 11:30:49 IST


On Thu, May 31, 2001 at 11:23:29AM +0100, James Cooper mentioned:
> I come from a Windows programming background.
> How do i compile a C source file into a library? (compiler switches etc)
> Do i need a .DEF file like in M$ Visual C++?
> For example, say i have the following C file:
>
> #include "whatever i need..."
>
> int MyDouble(int x) {
> return x << 1;
> }
>
> int MyHalf(int x) {
> return x >> 1;
> }
>
> What do i have to do to have a library that exports these functions?
> Thanks in advance,
> James

 gcc -o file1.lo -fpic -c file1.c
 gcc -o file2.lo -fpic -c file2.c
 gcc -o file.so -shared file1.lo file2.lo

 Should do it. -fpic says "Keep a register free so I can use it for
offsets later" (needed in a shared lib) and the lower line is a link
line....easy, no ?

Kate

-- 
 When I say 'free', I mean 'free': free from bond, of chain or command: 
to go where you will, even to Mordor, Saruman, if you desire. " 
    -- Gandalf, paraphrasing the choice between Free and Non-free software


This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:10:31 GMT