Mailing Lists: Apple Mailing Lists

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

ld and dyld_stub_binding_helper (was: Linking glib-based library from Cocoa app)



On Tuesday, November 4, 2003, at 11:03 PM, Peter O'Gorman wrote:

To build a loadable library on Mac OS X using gnu libtool, first you
should make sure that you have a working libtool. The one shipping with
panther is gnu libtool 1.5 with some apple patches. Run libtoolize
--force --copy as well as the other auto tools to regenerate configure
and all the Makefile.in's. That done, you may need to edit a couple of
Makefile.am's. If you want your library to be loadable, you will need to
add "-module" to the libfoo_la_LDFLAGS. This is normally used in
conjunction with "-avoid-version". When building a libfoo.la with the
-module flag, libtool will set the extension to .so and build a Mach-O
bundle. Without the -module flag, it will build a "Shared Library". Only
bundles may be opened with NSObjectFileImage/NSLinkModule, however
Shared libraries may be added at runtime using NSAddImage and/or
NSAddLibrary. The dlopen available on panther can open both types, but
works best with "bundles".


Thanks for all the information, Peter, but I was kind of hoping to be able to deliver an application that will compile and run on a standard-issue Mac running OSX 10.2.* with no need for pre-installs or hacks of any kind.

Unfortunately that goal appears to be a pipe-dream because I already depend on the availability of dlopen(), which implies that either dlcompat or Panther has been installed. Of course, I could just copy and streamline the dlcompat code and use the NS calls directly -- that's the only way I know to achieve my stated goal.


See the following:
man: ld(1), NSLinkModule(3), NSObjectFileImage(3), dyld(3), dlopen(3)
web: http://www.gnu.org/software/libtool/manual.html


I think at this point I need to get as low-level as possible so I can gain some glimmer of understanding of what's really going on. For example, I think I want to start doing everything with ONLY the "ld" command.

On that point, here's a problem maybe someone can help me with.

I am trying to build a run-time loaded (dlopen) library called fexl_test.so. I want to do this using only the ld command. So I try this:


ld -bundle ../obj/fexl_test.o libnode.dylib -o fexl_test.so -lc


(I use -lc to include the standard C library so I can use printf.)


The resulting error message is:

ld: Undefined symbols:
dyld_stub_binding_helper


What incantation can I include on the 'ld' command line to avoid this error?


-- Patrick
_______________________________________________
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: Linking glib-based library from Cocoa app (From: "Peter O'Gorman" <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.