[sane-devel] Re: Darwin/MacOSX

Henning Meier-Geinitz henning@meier-geinitz.de
Fri, 29 Nov 2002 20:18:12 +0100


Hi,

On Fri, Nov 29, 2002 at 11:48:30PM +0900, Peter O'Gorman wrote:
> Loadable modules on darwin should be linked with the -bundle flag to 
> apple's gcc (I'll just call it cc from now), objects created in that 
> manner may be loaded and unloaded using NSModule(3) and 
> NSObjectFileImage(3) functions. Objects linked with the -dynamiclib 
> option to cc may be loaded using NSAddLibrary, but can not be unloaded 
> and there is more overhead in loading them, it is discouraged. It used 
> to be the -install_name and -current_version flags to cc were accepted 
> quietly by gcc 2.95, but with the move to 3.1 these are errors. libtool 
> current has these changes, but it is otherwise broken on darwin/Mac OS 
> X, so it would probably require patches anyway. All current versions of 
> libtool on darwin will link loadable modules and name them 
> libxyz.{version}.so if passed the -module flag, if not passed that 
> flag, libtool will name the objects libxyz.{version}.dylib, as these 
> are not meant to be dynamically loaded, rather used as input to the 
> linker.

Ok, I think I understand now. So the solution would be to check for the
dynamic loading library and add LD_FLAGS=-module in configure.in, if
it's found. And add your patch to dll.c.

As the check for dlopen is already there, can you tell us, how to
check for MAcOS in configure? Ok, I could write a cpp test for
__APPLE__ but maybe there is a nicer way.

I think I'll wait with updating libtool some more time, beacuse it's a
major hazzle each time to include our local changes. Maybe everything
is fixed until then :-)

> Darwin does not come with dl functions, that is why we wrote the 
> dlcompat library currently used by fink darwinports and many other 
> projects, it was written for projects which expected to be able to load 
> and link against objects and which could not be easily patched to 
> behave properly (think KDE here). It is not necessary for sane to do 
> that.

Well, I don't think I fully understood that paragraph. Do users who
want to build sane-backends with dynamic loading need dlcompat?

Can you write some lines for README.darwin, so users know that they
must get this library and where they can get it?

> If you think your version is dynamically loading those dylibs, and you 
> do not have dlcompat installed, you are wrong (sorry), I think you will 
> probably find (use otool -L) that they are all linked into the 
> library/app, or you are magically linking against libdl.0.dylib 
> somewhere.

The filesize of the application or libsane.1.0.9.dylib will be a clue,
too :-)

Bye,
  Henning