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: dlopen



I will follow up on this, first please look at the available documentation:

man NSModule
man 3 dyld
man 1 dyld
man ld

Read these and you will be up and running.

You should be linking loadable modules with the -module flag, if for some reason the software you are porting requires the behavior that the module be both run time loaded and linked against then you might be able to use the dlcompat which is available on the fink package submissions tracker item:

http://sourceforge.net/tracker/?func=detail&aid=516734&group_id=17203&atid=
414256

(I didn't write it, it was written by Jorge Acereda Macia, and slightly modified by me).

There are some caveats to using dylibs as loadable modules.
1) If you need to have undefined symbols, you need -flat_namespace linkage.
2) You can't load dylibs locally, they must be global. - So no symbols may be the same even in different modules. (unless you didn't need undefined symbols, in which case you can use two level namespace).
3) You can't unload dylibs (although the dl spec says that this is okay, it is not expected behavior)
4) The module must dlopen and dlsym any symbols it needs from the application, Not required if linking with -module


The other problem is that the code on the tracker item may not work. No guarantees.

If you can avoid it, do not try to use dylibs (MH_DYLIB) as loadable modules, use MH_BUNDLE instead.

Also, the dlcompat currently in use by fink is a modification of the code available from the cctools project on darwin cvs. If you really want to get into the whole thing check it out.

Peter

On Sunday, March 17, 2002, at 06:49  AM, David R. Morrison wrote:

"ToolTech Darwin" <email@hidden> wrote:

We are missing the dlopen and therefor we have looked into the dyld methods.

When trying to map a .dylib file to an image I get an error
NS...InapropriateFile ??

What Is the correct way to link and compile dylib files so they are
compatible with .so files in Unix + dlopen,dlsym.

What can be wrong when I get the innapropriate file error ?

I am redirecting this to the unix-porting list.

Christoph Pfisterer wrote "dlcompat" which emulates dlopen on Darwin/OS X.
It is available from the fink project: see
http://sourceforge.net/projects/fink
to download dlcompat,
http://fink.sourceforge.net/doc/porting/shared.php
for some information about it, and
http://fink.sourceforge.net
for the fink project in general.


Note that although dlcompat is released as part of the fink project, it
can be used independently (and is in fact used by other projects such
as gnu-darwin).

-- Dave
_______________________________________________
unix-porting mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/unix-porting
Do not post admin requests to the list. They will be ignored.
_______________________________________________
unix-porting mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/unix-porting
Do not post admin requests to the list. They will be ignored.



References: 
 >Re: dlopen (From: "David R. Morrison" <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.