libtool
[Top][All Lists]
Advanced

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

Re: libtool C++ link bug with -lm functions with Sun Workshop compiler


From: Albert Chin
Subject: Re: libtool C++ link bug with -lm functions with Sun Workshop compiler
Date: Fri, 21 Mar 2008 10:52:26 -0500
User-agent: Mutt/1.5.17 (2007-11-01)

On Wed, Mar 19, 2008 at 07:03:38PM -0500, Tim Mooney wrote:
>
> I think I have discovered a bug in libtool's link behavior with the
> Sun Workshop C++ compiler when creating a C++ library that requires libm.
> I observed it on x86_64-sun-solaris2.10, but it may also affect the
> Workshop C++ compiler on Linux too.  I found it when trying to build
> GNU aspell 0.60.5.

What version of Sun C++ are you using?

> If you have a configure.ac that calls AC_LANG([C++]), any subsequent
> AC_CHECK_FUNCS will result in a link that uses the C++ compiler.  Because
> the C++ compiler initiates the link, it automatically adds some libraries
> to the final call to ld.  Which libraries it adds depends on what flags
> CC was passed (arguments like -library=stlport4 change what C++ libraries
> are automatically added).  The C++ compiler appears to always add `-lm
> -lc' after the C++ libraries, though.
>
> That means that doing something like
>
> AC_INIT(lttest, 0.60.5)
> AC_CONFIG_SRCDIR(configure.ac)
> AC_PROG_CXX
> AC_LANG([C++])
>
> AC_CHECK_FUNCS(sqrt)
> AC_OUTPUT
>
> will always detect sqrt(), because the C++ compiler added `-lm -lc'
> behind the scenes.
>
> When libtool is called to generate a C++ library on Solaris, it doesn't
> add -lm, though.  It only adds -lc.  That will result in link failures
> if functions like sqrt(), floor(), etc. from libm are used by the C++
> library.

But if Sun C++ automatically adds -lm -lc, why, with libtool using C++
to link the library, isn't -lm -lc automatically added? Because Sun C++
is creating a library and not a program?

-- 
albert chin (address@hidden)




reply via email to

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