Building and linking shared libaries for multiple different versions of UNIX

samba-technical at samba-technical at
Wed May 16 14:54:52 GMT 2001

On Wed, May 16, 2001 at 04:28:25PM +0900, Richard Sharpe wrote:
> I have to figure out some ways of making this portable so I can build
> shared libraries for lots of combinations.
> I do not want to force libtool on the Samba team, so I need to use other
> techniques.

Yet another person reinventing the wheel. Beautiful.

> Andrew has suggested that I need scripts to do the linking, and obviously,
> I need some configure test scripts to check if I can build shared libraries
> on each of the architectures we build for ... but I have some questions:
> 1. Do the flags for generating PIC differ from system to system, esp if
> using the native compilers?
> If so, I imagine I can get away with defining the appropriate flags
> (PICFLAGS) and passing them to the compiler in Makefile.
> 2. Can I get away with defining something like SOLDFLAGS, and simply pass
> that to $(LD)?
> 3. Any hints would be appreciated ... I think I will go and look at CUPS to
> see if Michael Sweet has dealt with this before.

Will you:
  1. chmod the shared library to +x on HP-UX?
  2. Make the shared library extension on HP-UX 'sl' rather than 'so'?
  3. Is there just one shared library? If more than one, are they
     dependent on each other? If so, do you plan on hard-coding the
     runtime path of the installation library directory in the
     shared libraries?
  4. Are you linking against any 3rd-party libraries (OpenSSL, KRB,
     etc.)? If so, do you plan to add runtime paths to each of
     these to your library (in which case -rpath won't work
  5. On AIX, you need to run '/bin/nm ...' to create a list of
     the exported symbols and then pass the file created as output
     to ld before generating the shared library.
  6. Will you allow creating static *and* shared libraries at the
     same time? If you do, then handling shared libraries on AIX
     becomes more interesting.
  7. How do you plan on versioning the library?
  8. Will you embed an soname in the snamed library (cf -soname on
     Linux ld).
  9. Will smbd, nmdb, etc. be linked against your shared library?
     If so, HP-UX and other platforms hardcode -L paths into the
     binary. Libtool first installs the shared library and then
     relinks the executables at install time so the correct
     runtime path is inserted into the binary. Will you do this?
     Or support the +b option on HP-UX ld (if you do, the binaries
     will work after being installed but *not* before).

Libtool will make your life easier.

albert chin (china at

More information about the samba-technical mailing list