[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -lm -lz

From: Bob Proulx
Subject: Re: -lm -lz
Date: Thu, 6 Mar 2008 09:21:05 -0700
User-agent: Mutt/1.5.13 (2006-08-11)

Stefan Bienert wrote:
> after an hour of searching, how am I supposed to invoke "-lm -lz" into 
> my compilation? The documentation states something about using "LIBS" as 
> a variable, autoconf also speaks of "LIBS" but nobody tells one what to 
> do with that variable.

LIBS is inherited from autoconf and is documented there.  You can get
a quick usage by invoking './configure --help' to get a help listing
from it.

  ./configure --help | grep LIBS
  LIBS        libraries to pass to the linker, e.g. -l<library>

It would be used by autoconf's generated configure script this way:

  ./configure LIBS="-Something_user_special"

But for automake you should look in the section describing how to link
programs.  You would want to put your flags there.

In the automake manual look for the section "Linking the program".

  8.1.2 Linking the program

  If you need to link against libraries that are not found by
  `configure', you can use `LDADD' to do so.  This variable is used to
  specify additional objects or libraries to link with; it is
  inappropriate for specifying specific linker flags, you should use
  `AM_LDFLAGS' for this purpose.  

     Sometimes, multiple programs are built in one directory but do not
  share the same link-time requirements.  In this case, you can use the
  `PROG_LDADD' variable (where PROG is the name of the program as it
  appears in some `_PROGRAMS' variable, and usually written in lowercase)
  to override the global `LDADD'.  If this variable exists for a given
  program, then that program is not linked using `LDADD'.  
     We recommend that you avoid using `-l' options in `LDADD' or
  `PROG_LDADD' when referring to libraries built by your package.
  Instead, write the file name of the library explicitly as in the above
  `cpio' example.  Use `-l' only to list third-party libraries.  If you
  follow this rule, the default value of `PROG_DEPENDENCIES' will list
  all your local libraries and omit the other ones.

Since you are referring to third party libraries (libraries not built
by you in your build) using LDADD or PROG_LDADD is appropriate.

Something like this in your file:

  bin_PROGRAMS = foo
  foo_SOURCES = foo.c
  LDADD = -lm -lz

Or for the PROG_LDADD program specific version:

  bin_PROGRAMS = foo
  foo_SOURCES = foo.c
  foo_LDADD = -lm -lz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]