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
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!