• 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: Newbie to Darwin linking issue I think?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie to Darwin linking issue I think?


  • Subject: Re: Newbie to Darwin linking issue I think?
  • From: Damien Cooke <email@hidden>
  • Date: Sun, 5 Jun 2005 09:25:26 +0930

Thanks for the hint:

I am now linking like this

cc -dynamiclib -fPIC -o bin/liblpmalloc.so output/lpmalloc.o output/ global.o

But I now get:

ld: warning multiple definitions of symbol _malloc
output/lpmalloc.o definition of _malloc in section (__TEXT,__text)
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/../../../libSystem.dylib (malloc.So) definition of _malloc


So how do I tell it I am building a replacement for malloc other than re-implementing the System.dylib ? Is there a way of dropping duplicate entries?

Damien


On 05/06/2005, at 8:51 AM, Shantonu Sen wrote:


Why are you using libtool(1) instead of the compiler driver cc(1) to create your shared library?

Your problem is that you are not linking against libSystem.dylib (via -lSystem). You're also missing a host of other libraries automatically included when you link a dylib with cc(1). for example:

/usr/bin/libtool -dynamic -arch_only ppc -noall_load - weak_reference_mismatches non-weak -v -o libfoo.dylib -L/usr/lib/ gcc/powerpc-apple-darwin8/4.0.0 -L/usr/lib/gcc/powerpc-apple- darwin8/4.0.0 -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/../../.. foo.o -lgcc -lgcc_eh -lSystemStubs -lmx -lSystem

You should use cc/gcc and the -dynamiclib option to build your library. You probably also want to read the various man pages and use the -install_name flag as well.

Shantonu

On Jun 4, 2005, at 4:06 PM, Damien Cooke wrote:



Sorry for the dumb question. I am porting my malloc to Darwin. I have built it as a shared dynamic library on Solaris. However I am having a large amount of problems with this on OS X 10.4.1 using XCode 2.0 and gcc 4.0

I build the two object files as such

gcc -g -fPIC -c source/lpmalloc.c -o output/lpmalloc.o
gcc -g -fPIC -c source/global.c -o output/global.o

Then I use Libtool as such libtool -dynamic -o bin/liblpmalloc.so output/lpmalloc.o output/global.o

This is what I get:

ld: for architecture ppc
ld: Undefined symbols:
_printf
libtool: internal link edit command failed


I am probably doing something really dumb but any help would be greatly appreciated.


Damien

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40opendarwin.org


This email sent to email@hidden








_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Newbie to Darwin linking issue I think?
      • From: Shantonu Sen <email@hidden>
References: 
 >Newbie to Darwin linking issue I think? (From: Damien Cooke <email@hidden>)
 >Re: Newbie to Darwin linking issue I think? (From: Shantonu Sen <email@hidden>)

  • Prev by Date: Re: Newbie to Darwin linking issue I think?
  • Next by Date: Re: Newbie to Darwin linking issue I think?
  • Previous by thread: Re: Newbie to Darwin linking issue I think?
  • Next by thread: Re: Newbie to Darwin linking issue I think?
  • Index(es):
    • Date
    • Thread