• 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: dynamic libraries prpoblem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic libraries prpoblem


  • Subject: Re: dynamic libraries prpoblem
  • From: "Ivan S. Kourtev" <email@hidden>
  • Date: Tue, 21 Jun 2005 21:48:05 -0400

Thanks for the reply. Yes, there are differences. And they are obscure at best!

On Jun 21, 2005, at 7:52 PM, Michael McCracken wrote:

Hi, The short answer is that linux and darwin diverge a good bit when
it comes to linking, and you may indeed need to do different things
for OS X. Your best bet is to read some manpages, keeping the
following in mind:
For apple's gcc, -dynamiclib tells it to create a dynamic library
using darwin libtool, which is not the same as gnu libtool. gnu
libtool is available on darwin as 'glibtool'.
Also, ld is the mach link editor, and is not the same as linux's ld.
From the manpages, it looks like calling 'g++ -dynamiclib' will end up
calling 'libtool -dynamic', which calls 'ld -dylib'.
Since the command you mentioned is operating on preexisting object
files, how were they built?

The object files are compiled here, using '-c -fPIC -g' flags. I also tried using the -dynamic flag during compilation (read somewhere that you may want to do that for building dynamic libraries) but it didn't seem to help.


The libtool tip was good actually, I managed to build almost all static and dynamic libraries with 'libtool -static' and 'libtool - dynamic' and actually gort everything to almost build. Still fighting a few undefined symbols here and there.

Also, for further reference - Apple has some docs for porting from
unix [1] and another mailing list that might be of more help called
unix-porting  [2]

[1]:http://developer.apple.com/documentation/Porting/Conceptual/ PortingUNIX/intro/chapter_1_section_1.html

Yes, I got these but they didn't help me much. Apple has a lot of warnings (about how linking in Mac OS X is different) in at east 10+ different documents but I failed to find a step-by-step guide.


[2]:http://lists.apple.com/archives/Unix-porting/

On 6/21/05, Ivan S. Kourtev <email@hidden> wrote:

This may be perhaps a bit off topic but I am having problems
subscribing to the Darwin-dev list so I thought I'd start by asking
here.

I am having problems compiling and using Linux code that involves
building some shared libraries.  I am trying to build a shared
dynamic library from some foo*.o files with a line like this:

g++ -dynamiclib foo1.o foo2.o -o libBar.so

But the above line fails with an "ld: Undefined symbols:" error
followed by a long list of symbols. All of the missing symbols are
defined in another dynamic library libExtra.so located in the folder /
location


So if I try the following line

g++ -dynamiclib foo1.o foo2.o -L/location -lExtra -o libBar.so

everything works fine, no complaints.

Why is that?  I was under the impression that it is not necessary for
the linker to be able to resolve the references at the time of
building the dynamic library?  I am not a big expert on this and it
seems dynamic libraries on Mac OS X are somewhat different but I am
having trouble figuring out what's going on.  Is the first version of
the command (above) never going to work on Mac OS X and I just have
to stick to the second?  Thanks in advance for any help,

Cheers,

-- ivan




-- ivan (Ivan Kourtev) Assistant Professor, 348 Benedum Hall Phone: 412.624.9088 Dept. of Electrical and Computer Engineering Fax: 412.624.8003 University of Pittsburgh Email: email@hidden Pittsburgh, PA 15261, USA

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


References: 
 >dynamic libraries prpoblem (From: "Ivan S. Kourtev" <email@hidden>)
 >Re: dynamic libraries prpoblem (From: Michael McCracken <email@hidden>)

  • Prev by Date: Re: How to set a default row in NSTableView?
  • Next by Date: Re: CoreData performance issues
  • Previous by thread: Re: dynamic libraries prpoblem
  • Next by thread: Sync pull order and to-many relationships
  • Index(es):
    • Date
    • Thread