unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Jan Nieuwenhuizen <janneke-list@xs4all.nl>
Cc: "Ludovic Courtès" <ludo@gnu.org>,
	"Bruno Haible" <bruno@clisp.org>,
	guile-devel@gnu.org
Subject: problems solved by AC_LIB_HAVE_LINKFLAGS [was: cross building 1.9.14 for mingw]
Date: Fri, 04 Mar 2011 12:11:20 +0100	[thread overview]
Message-ID: <m3lj0vdtt3.fsf_-_@unquote.localdomain> (raw)
In-Reply-To: <1298540378.4306.71.camel@vuurvlieg> (Jan Nieuwenhuizen's message of "Thu, 24 Feb 2011 10:39:38 +0100")

Hi Jan,

Apologies for the delay in the reply.

On Thu 24 Feb 2011 10:39, Jan Nieuwenhuizen <janneke-list@xs4all.nl> writes:

> Andy Wingo schreef op di 22-02-2011 om 09:34 [+0100]:
>
>> To be honest I don't find it too onerous to have to set these flags when
>> compiling with DESTDIR.  Sure, it would be nicer if it were just one
>> flag, and perhaps we can fix that; but as you have perhaps seen in the
>> numerous discussions on bug-guile recently, it seems that
>> AC_LIB_HAVE_LINKFLAGS solves real problems.
>
> I'm glad to hear that, at least it means that my cross build troubles
> were for a good cause...  So now I need to look into the problems
> that AC_LIB_HAVE_LINKFLAGS actually solves and see how to keep solving
> them while not breaking zero-config DESTDIR-builds.

Here is my understanding of the problems and solutions.

Let's say you are building and installing Guile on Fedora.  You download
the tarball, ./configure && make && make install, and voila.  You run
Guile and it works.  Sweet!

So now you follow the manual, and it says that you can build your own
Guile via:

 $ gcc -o simple-guile simple-guile.c $(pkg-config guile-2.0 --cflags --libs)

which in your case expands out to

 $ gcc -o simple-guile simple-guile.c -I/usr/local/include/guile/2.0 -L/usr/local/include -lguile-2.0

And it compiles and links.  Awesome.

However when you run the simple-guile it doesn't work:

 $ ./simple-guile
 error: could not find libguile-2.0.so

Why is this?  It's because in Fedora, /usr/local/lib is not in the
default runtime library search path.

If we were compiling on Debian this would work because /usr/local/lib is
in the default library search path, though we would see the issue if we
installed to (e.g.) /opt/guile.

If we were compiling on Mac OS X it would work fine because the linker
effectively adds -rpath for libraries not in the standard locations
(even the /opt/guile case).

Those of us that haven't linked anything on the command line in a while
probably haven't noticed, because we use libtool to do the linking, and
libtool will add -rpath when linking against libraries that are not in
your system run path.

It used to be that libtool always added -rpath, but distros complained
-- Debian for one -- and so now libtool only adds -rpath for libs that
are not going to a system path.

It seems that what libtool does is the right thing to do by default.
The problem is, you can't add the -rpath in guile-config or pkg-config
-- the right thing to do depends on the compiler you are using.  So you
have to check for that at configure-time.  That's what
AC_LIB_HAVE_LINKFLAGS does.  Given some link-time flags,
AC_LIB_HAVE_LINKFLAGS determines what flags will be needed such that the
library will be found at runtime.  It adds -rpath when linking against
libraries that are not in your system path.

This discussion about system paths usually includes /usr, so that's the
default behavior of AC_LIB_HAVE_LINKFLAGS.  But sometimes you don't want
AC_LIB_HAVE_LINKFLAGS to look there -- that is, when you have $DESTDIR
builds -- and so in that case there are all those
--without-PACKAGE-prefix arguments.

That's the problem that AC_LIB_HAVE_LINKFLAGS solves for normal
"configure && make && make install" users.  It can complicate $DESTDIR
builds a little, in that you have to add some more configure arguments,
but it's not that bad.

Peace,

Andy
-- 
http://wingolog.org/



  parent reply	other threads:[~2011-03-04 11:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-29 19:41 cross building 1.9.14 for mingw Jan Nieuwenhuizen
2011-01-29 21:34 ` Ludovic Courtès
2011-01-31 20:16   ` Jan Nieuwenhuizen
2011-01-31 20:44     ` Ludovic Courtès
2011-02-15 10:20   ` Jan Nieuwenhuizen
2011-02-22  8:34     ` Andy Wingo
2011-02-24  9:39       ` Jan Nieuwenhuizen
2011-02-24 10:37         ` Ludovic Courtès
2011-03-04 11:11         ` Andy Wingo [this message]
2011-03-20  8:08           ` problems solved by AC_LIB_HAVE_LINKFLAGS [was: cross building 1.9.14 for mingw] Jan Nieuwenhuizen
2011-03-20  8:21             ` Ralf Wildenhues
2011-03-20  8:34               ` Jan Nieuwenhuizen
2011-03-20  8:56                 ` Ralf Wildenhues
2011-01-29 21:39 ` Relocatable installation Ludovic Courtès
2011-01-31 20:26   ` Jan Nieuwenhuizen
2011-01-31 20:50     ` Andy Wingo
2011-01-31 20:55       ` Jan Nieuwenhuizen
2011-01-31 21:30         ` Andy Wingo
2011-01-31 21:49           ` Jan Nieuwenhuizen
2011-01-31 21:00     ` Ludovic Courtès
2011-01-31 21:18       ` Jan Nieuwenhuizen
2011-01-31 22:09         ` Ludovic Courtès
2011-01-31 22:26           ` Jan Nieuwenhuizen
2011-02-14 12:29 ` cross building 1.9.14 for mingw Ludovic Courtès
2011-02-15 10:02   ` Jan Nieuwenhuizen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3lj0vdtt3.fsf_-_@unquote.localdomain \
    --to=wingo@pobox.com \
    --cc=bruno@clisp.org \
    --cc=guile-devel@gnu.org \
    --cc=janneke-list@xs4all.nl \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).