Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Continuing Linux Porting issues



On 07/05/2004 at 1:45 PM, email@hidden wrote:

> If I add an _init symbol to each libaray that I'm going to dlopen (so
> I can dlsym it to force the library to initialize itself) it works
> pretty good EXCEPT if I have cross-library dependencies, then I get
> problems with multiply defined _init symbols. ie: if libfoo.dylib
> depends on libbar.dylib then I link libfoo.dylib with -lbar and get a
> multiply defined _init symbol.
>
> I'm currently thinking about putting a unique symbol in each library
> (ie: _init_foo, _init_bar) but this seems like a really nasty way to
> solve the problem. Is there something better? Either a way to get
> around the multiply defined symbols or some existing symbol in each
> library I can lookup?

Yes, this is a really nasty way to solve the problem. It is also
exactly how I chose to solve the problem :) My build system
automatically code generates a file that contains a function whose name
is derived from the name of the dynamic library (e.g., _foo) and
compiles this file into the dynamic library. With this approach, you
shouldn't have to modify your 100 or so libraries, just your build
system.

> Greg Corson wrote:
>
>> The main implementation problem I have is that there is no common
>> symbol in all of my .dylib files to lookup. I really don't want to
>> add code to put, say, an _init and associated #ifdef OSX kind of code
>> into all 100 or so libraries. Is there some symbol guaranteed to be
>> in every library that I could lookup with dlsym? (or some way to add
>> one from the command line during compile/link?)

I'm not aware of a symbol that is available from every library. In
fact, if there was one, you would get multiply defined symbol errors
like you previously mentioned.

>> I tried dumping the libraries with otool and found a few common
>> symbols like ___initialize_Cplusplus, __dyld_func_lookup and the
>> (supposedly) linker defined symbol __mh_dylib_header but dlsym
>> couldn't find any of these (maybe they are not exported?)

I don't believe these symbols are exported. The nm tool is helpful to
determine which symbols are exported from your dynamic library.
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: Continuing Linux Porting issues (From: email@hidden)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.