• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: libraries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libraries


  • Subject: Re: libraries
  • From: Tomas Zahradnicky <email@hidden>
  • Date: Mon, 21 Jul 2003 08:11:45 +0200

Ok, I've just wrecked my eyes and brain reading through the man pages for
both gcc and ld, and I still can't quite get my head around how to do
something that i KNOW has got to be really simple.

All I want to do is build a library (in standard C) with a couple of
functions in it, then include it in my project, and use it.

For testing, I've been just using one dummy function:

int adder(int a, int b) {
return (a+b);
}

I compiled like this first:

gcc adder.c -object

which wouldn't work, because gcc wanted me to use the "-static" flag. So
then I tried:

gcc adder.c -static -object

which couldn't find some symbol(s), so I did:

gcc adder.c -nostdlib -static -object

this is ok, but it doesn't build a lib. This only builds object code. To make it a lib you have to use "ar" to make it an archive and then "ranlib" tool to make toc of the archive created.

i.e. make static library from 2 files

gcc2 adder.c -nostdlib -static -object -o adder.o
gcc2 multiplier.c -nostdlib -static -object -o multiplier.o
ar -r arithmetics.a adder.o multiplier.o
ranlib arithmetics.a


-Tomas
--
Ing. Tomas Zahradnicky, Jr.
Production Manager, 24U Software
Associate Member, Filemaker Solutions Alliance
mailto:email@hidden
http://www.24uSoftware.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: libraries
      • From: "Alastair J.Houghton" <email@hidden>
    • Re: libraries
      • From: Philip George <email@hidden>
References: 
 >libraries (From: Philip George <email@hidden>)

  • Prev by Date: weird NSAppleScript error
  • Next by Date: determining encoding on documents
  • Previous by thread: libraries
  • Next by thread: Re: libraries
  • Index(es):
    • Date
    • Thread