🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
3 messages
3 total messages Started by Paul F. Kunz Thu, 21 Jan 1993 05:49
NXBundles and external libraries
#2170
Author: Paul F. Kunz
Date: Thu, 21 Jan 1993 05:49
47 lines
2657 bytes
   I would appreciate advice on how to best handle the following 
situation...

   I have a large body of code with nibs which I've encapsulated in to
a NXBundle.  The code makes calls to an external library package.  The
purpose of the bundle is so that a number of other applications can
load this bundle rather than compiling and linking their own copies of
the source code.  These other applications also link against the same
external library, but far fewer members of the library.

   The problem is how do I get all the external references from the 
library resolved at run time and yet get the application to build.
That is, if the application links against the external library, it
only pulls out a few members and when the bundle loads, there will
be many missing external symbols.   When I build the bundle I could
include the library, but then I'll get duplicate segment problems.

   The two ideas I have to solve this problem; which might also help
clarify what I'm talking about, are the following...

- Method 1:
	o force the loading of the entire library into the bundle.
	o don't link the Application against the library.
	o tell the linker with the -U option to ignore the few undefined
	  symbols when building the application.
	o Make sure that the application loads the bundle before attempting
	  to use any functions in the library.

The bundle needs the entire library anyway, so the first item is not 
a problem.   Asking each application builder to list their references
to the library via the -U mechanism is rather unpleasant.

- Method 2:
	o don't load the library with the bundle.
	o force the loading of the entire library in the application
	  with the -all_load option of ld

'-all_load' option seems to work on all libraries, so I'll have to take
extra steps so it applies only to this one library.

   I think method 2 makes more sense, but haven't tried it yet.   But
I'm wondering if I'm missing an even better mechanism to accomplish
this.   Any suggestions?
--
Paul F. Kunz	pfkeb@slac.stanford.edu (NeXT mail ok)
Stanford Linear Accelerator Center, Stanford University
Voice: (415) 926-2884   (NeXT) Fax: (415) 926-3587
Re: NXBundles and external libraries
#2218
Author: Ed Nicolson
Date: Thu, 21 Jan 1993 18:41
46 lines
2523 bytes
In article <PFKEB.93Jan20214908@kaon.SLAC.Stanford.EDU>  
pfkeb@kaon.SLAC.Stanford.EDU (Paul F. Kunz) writes:
>    I would appreciate advice on how to best handle the following 
> situation...
> 
>    I have a large body of code with nibs which I've encapsulated in to
> a NXBundle.  The code makes calls to an external library package.  The
> purpose of the bundle is so that a number of other applications can
> load this bundle rather than compiling and linking their own copies of
> the source code.  These other applications also link against the same
> external library, but far fewer members of the library.
> 
I have a similar question.  When distributing a custom Palette I
need to distribute a library of the object code along with the
Palette, which I believe is a bundle.   The Palette contains my
custom subclass of IBPalette (MyIBPalette) along with other classes I have
created.  The palette (bundle) also contains nib and tiff files
that the other classes need.  To get those resources I use 

bundle = [NXBundle bundleForClass: [MyIBPalette class]];
[bundle getpath:buf forResource .....]

in the code for the other classes.

To create the library I took all the object code files from the 
   palette and used ar and ranlib to create a library which I link in 
   with the application using the custom Palette.  This gives the message:

/bin/ld: Undefined symbols:
objc_class_name_IBInspector
_IBObjectPboardType
objc_class_name_IBPalette

Questions:

a) Is there another library other than the standard -lMedia_s -lNeXT_s
   that could be linked to solve this problem (I could not find one.)

b) Should I not be using the class MyIBPalette to be the class 
   "holding" the bundle for all the custom palette resources since
    the application will not require the IBInspectors and IBPalette
    classes during execution.  It only needs them when running
    Interface Builder.

Ed Nicolson
nicolson@robotics.berkeley.edu
Re: NXBundles and external libraries
#2268
Author: Paul F. Kunz
Date: Sat, 23 Jan 1993 04:28
40 lines
2218 bytes
   After a day of puting out fires in other areas, I came back to this
problem and it turned out quite easy.  The problem was that a
dynamically loaded bundle and the staticly loaded code in an
application resolved external symbols from the same external non-NeXT
C library where the bundle needed many more symbols than the
application.

   Here's what I did...

In Makefile.preamble of the application, I put in

	LLIBS = /usr/local/lib
	OTHER_OFILES = obj/hippo.o
	LIBHIPPO = $(LLIBS)/libhippoNext.a

where libhippoNext.a is the C library in question.

In Makefile.postamble of the applicaton, I put in

	obj/hippo.o : $(LIBHIPPO)
		ld -all_load -r -o $@ $(LIBHIPPO)

This dependency rule forces all of libhippoNeXT.a to be linked
re-locateable into the file obj/hippo.o and since obj/hippo.o has been
declared as an "OTHER_OFILE" everything works.   That is, the application
links without errors due to unresolved sysmbols, and the bundle loads
also without errors due to unresolved symbols.

   Obviously, this is a good solution only if you essentially need all
of the library in the application anyway, which is my case.  The real
answer to the problem is to build a shared library, but nobody but a
few gurus at NeXT know how to build a shared library on a NeXT.

   I have nobody to thank for suggestions or solutions to my question
since I didn't get any via the news group nor by e-mail.   This must
be one of the rare cases where the net didn't come thru.
--
Paul F. Kunz	pfkeb@slac.stanford.edu (NeXT mail ok)
Stanford Linear Accelerator Center, Stanford University
Voice: (415) 926-2884   (NeXT) Fax: (415) 926-3587
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads