From jan@swi.psy.uva.nl Fri Apr 13 11:13:25 2001
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f3D9DP326985;
	Fri, 13 Apr 2001 11:13:25 +0200 (MET DST)
Received: (from jan@localhost)
	by gollem.swi.psy.uva.nl (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f3D9DOY25427;
	Fri, 13 Apr 2001 11:13:24 +0200
Date: Fri, 13 Apr 2001 11:13:24 +0200
Message-Id: <200104130913.f3D9DOY25427@gollem.swi.psy.uva.nl>
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Subject: Re: dynamic linking on FreeBSD (probably NetBSD as well)
To: Brad Knotwell <knotwell@ix.netcom.com>
In-Reply-To: Brad Knotwell's message of Thu, 12 Apr 2001 21:39:35 -0700 (PDT)
Phone: +31 - 20 - 525 6121
Cc: prolog@gollem.swi.psy.uva.nl

Brad,

[ CC'ed to the mailing list, to see whether there are any experts on these
  issues around
]

> You had wondered about the flags for dynamic linking on the Free|Net
> BSD.  I think the following flags should work for both (probably
> OpenBSD and BSD/OS 4.X (definitely *not* 3.X) as well):
> 
> 	gcc -o unix.so -shared -fPIC /usr/local/prolog/lib/pl-4.0.3/runtime/i386-freebsd4.3/libpl.a error.> o process.o 
> 
> I suspect there's a way to do with ld as well, but the appropriate ld
> incantations have always escaped me.  Of course, if it was early and I
> was still chipper, I would've elegantly used the -L and -l options.

I prefer using gcc anyhow, as it generally hides most of the ld and
platform problems from the user.

Together with the remarks below however, this worries me a bit.  On most
(sofar all but AIX) Unix systems creating a shared object can be done
without refering the object you're later going to link too.  With a
proper gcc installation the command should always be

	gcc -o object.so -shared object.o ...

-fPIC (and -fpic) are compilation options, so as long as you do not provide
any .c files you should not need it.  Sometimes you need to add -l<lib>
for required shared objects that are not required by Prolog itself (like
the X11 libraries are required by XPCE).

Adding libpl.a probably adds a good deal of the Prolog kernel to your
shared object.  That cannot be our goal.  You may check so using the nm
utility.

> I've included yet another change to a Makefile.in (in this case, I
> changed clib's).  It makes the build work if you haven't updated your
> PATH variable yet after a new install (or more appropriately, you're
> installing as root but working as a normal user. . .root's probably
> not gonna have the correct environment).  I haven't looked at the
> other packages, but I suspect they've similar issues.

That is an issue.  Currently you're obliged to have the target
installation directory in your PATH.  I'm afraid this will require
more changes though.

	--- Jan

> --Brad (who can't believe he's enjoying working on build issues)

:-)

