Thread: Build error: math library not linked

Build error: math library not linked

From
"P. Christeas"
Date:
after trying my luck with lighthouseapp, let me post the bug here:

I upgraded to mageia α2, which uses python2.7 . Trying to build psycopg2 again
for it, stumbled accross unresolved errors for the floating point functions.
Indeed, final linking step didn't include "-lm" to the linker.

Added it with commit 4e29da5cda6aa3, as found at:
http://members.hellug.gr/xrg/repos/psycopg2
(browse at http://git.hellug.gr/?p=xrg/psycopg2)

Please check your platforms. Is libm already linked against? Could you
forecast any side-effect from explicitly mentioning it (as in the patch) ?


--
Say NO to spam and viruses. Stop using Microsoft Windows!

Re: Build error: math library not linked

From
Federico Di Gregorio
Date:
On 13/03/11 23:21, P. Christeas wrote:
> I upgraded to mageia α2, which uses python2.7 . Trying to build psycopg2 again
> for it, stumbled accross unresolved errors for the floating point functions.
> Indeed, final linking step didn't include "-lm" to the linker.
>
> Added it with commit 4e29da5cda6aa3, as found at:
> http://members.hellug.gr/xrg/repos/psycopg2
> (browse at http://git.hellug.gr/?p=xrg/psycopg2)
>
> Please check your platforms. Is libm already linked against? Could you
> forecast any side-effect from explicitly mentioning it (as in the patch) ?

On my Linux box libm is not linked in and I don't have any problem. Can
you please tell us you system version and the exact errors?

federico

--
Federico Di Gregorio                         federico.digregorio@dndg.it
Studio Associato Di Nunzio e Di Gregorio                  http://dndg.it
              Una nazionale senza neanche una nazione. -- macchinavapore

Re: Build error: math library not linked

From
"P. Christeas"
Date:
On Monday 14 March 2011, Federico Di Gregorio wrote:
> On 13/03/11 23:21, P. Christeas wrote:
> > I upgraded to mageia α2, which uses python2.7 . Trying to build psycopg2
> > again for it, stumbled accross unresolved errors for the floating point
> > functions. Indeed, final linking step didn't include "-lm" to the
> > linker.
> >
> > Added it with commit 4e29da5cda6aa3, as found at:
> > http://members.hellug.gr/xrg/repos/psycopg2
> > (browse at http://git.hellug.gr/?p=xrg/psycopg2)
> >
> > Please check your platforms. Is libm already linked against? Could you
> > forecast any side-effect from explicitly mentioning it (as in the patch)
> > ?
>
> On my Linux box libm is not linked in and I don't have any problem. Can
> you please tell us you system version and the exact errors?
>
> federico

Do you use -Wl,no-undefined at the linker? My problem is at that step, and I
highly suspect that if I hadn't had that, the binary (psycopg.so) would still
run against the python binary (because python will load libm anyway).



--
Say NO to spam and viruses. Stop using Microsoft Windows!

Re: Build error: math library not linked

From
Federico Di Gregorio
Date:
On 14/03/11 13:59, P. Christeas wrote:
> On Monday 14 March 2011, Federico Di Gregorio wrote:
>> > On 13/03/11 23:21, P. Christeas wrote:
>>> > > I upgraded to mageia α2, which uses python2.7 . Trying to build psycopg2
>>> > > again for it, stumbled accross unresolved errors for the floating point
>>> > > functions. Indeed, final linking step didn't include "-lm" to the
>>> > > linker.
>>> > >
>>> > > Added it with commit 4e29da5cda6aa3, as found at:
>>> > > http://members.hellug.gr/xrg/repos/psycopg2
>>> > > (browse at http://git.hellug.gr/?p=xrg/psycopg2)
>>> > >
>>> > > Please check your platforms. Is libm already linked against? Could you
>>> > > forecast any side-effect from explicitly mentioning it (as in the patch)
>>> > > ?
>> >
>> > On my Linux box libm is not linked in and I don't have any problem. Can
>> > you please tell us you system version and the exact errors?
>> >
>> > federico
> Do you use -Wl,no-undefined at the linker? My problem is at that step, and I
> highly suspect that if I hadn't had that, the binary (psycopg.so) would still
> run against the python binary (because python will load libm anyway).

In fact compiling with --no-undefined throws a lot of errors. Can I ask
you why you use it? If it is the correct thing to do we should add
--no-undefined to all builds and pull in the right libraries.

federico

--
Federico Di Gregorio                         federico.digregorio@dndg.it
Studio Associato Di Nunzio e Di Gregorio                  http://dndg.it
 In science one tries to tell people, in such a way as to be understood
  by everyone, something that no one ever knew before. But in poetry,
  it's the exact opposite.                                 -- Paul Dirac

Re: Build error: math library not linked

From
"P. Christeas"
Date:
On Monday 14 March 2011, Federico Di Gregorio wrote:
> On 14/03/11 13:59, P. Christeas wrote:
> > Do you use -Wl,no-undefined at the linker? My problem is at that step,
> > and I highly suspect that if I hadn't had that, the binary (psycopg.so)
> > would still run against the python binary (because python will load libm
> > anyway).
>
> In fact compiling with --no-undefined throws a lot of errors. Can I ask
> you why you use it? If it is the correct thing to do we should add
> --no-undefined to all builds and pull in the right libraries.
>

Found the reference:
http://wiki.mandriva.com/en/Underlinking#ld_option_--no-undefined
The paragraphs above that explain the rationale.

I stick with their policy (carried over to Mageia, now) and wish that our
build instructions fit that.


--
Say NO to spam and viruses. Stop using Microsoft Windows!

Re: Build error: math library not linked

From
Daniele Varrazzo
Date:
On Mon, Mar 14, 2011 at 2:09 PM, Federico Di Gregorio
<federico.digregorio@dndg.it> wrote:

> In fact compiling with --no-undefined throws a lot of errors. Can I ask
> you why you use it? If it is the correct thing to do we should add
> --no-undefined to all builds and pull in the right libraries.

"man floor(3)" says that link should be done with -lm, so I think it's
probably just thanks to a tolerant linker that the problem has not
emerged before (I don't know then if this level of tolerance is the
least we can expect or if gcc is a very patient guy).

Is it safe enough to add -lm to the linker flags for all the other
distro? I think so - but I'm no authority on linking at all. I don't
think instead we should be as strict as add --no-undefined: maybe
having a mandriva builder in the build farm to check for regressions
would be enough (it would be great if Christeas could provide it).

-- Daniele

Re: Build error: math library not linked

From
Federico Di Gregorio
Date:
On 16/03/11 12:29, Daniele Varrazzo wrote:
> On Mon, Mar 14, 2011 at 2:09 PM, Federico Di Gregorio
> <federico.digregorio@dndg.it> wrote:
>
>> > In fact compiling with --no-undefined throws a lot of errors. Can I ask
>> > you why you use it? If it is the correct thing to do we should add
>> > --no-undefined to all builds and pull in the right libraries.
> "man floor(3)" says that link should be done with -lm, so I think it's
> probably just thanks to a tolerant linker that the problem has not
> emerged before (I don't know then if this level of tolerance is the
> least we can expect or if gcc is a very patient guy).
>
> Is it safe enough to add -lm to the linker flags for all the other
> distro? I think so - but I'm no authority on linking at all. I don't
> think instead we should be as strict as add --no-undefined: maybe
> having a mandriva builder in the build farm to check for regressions
> would be enough (it would be great if Christeas could provide it).

At least on Debian (Ubuntu), RedHat and OpenSUSE should be fine.
Adding --no-undefined also seems a good idea to catch future errors.

federico

--
Federico Di Gregorio                         federico.digregorio@dndg.it
Studio Associato Di Nunzio e Di Gregorio                  http://dndg.it
  Those who do not study Lisp are doomed to reimplement it. Poorly.
                                     -- from Karl M. Hegbloom .signature