Re: [Vala] vala+automake bug?



On Tue, 2012-07-31 at 08:33 +0800, Nor Jaidi Tuah wrote:
Dear all,

My project (pasang-emas.sourceforge.net) uses automake,
using AM_PROG_VALAC macro in the configure.ac file.
It uses functions from Math (Math.sin, Math.hypot etc).

Recently, one user complains that upon issuing
'./configure' and 'make', he got the following error:

/usr/bin/ld: note: 'hypot@@GLIBC_2.2.5' is defined in
DSO /lib64/libm.so.6 so try adding it to the linker command line
/lib64/libm.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[2]: *** [pasang-emas] Error 1

He has to manually add -lm to the Makefile to
make 'make' work.

My questions:
* Shouldn't AM_PROG_VALAC take care of adding -lm?

No, that macro just finds valac and checks the version.  It has nothing
to do with C flags or libraries.

Since you're using the Vala support built into autotools you're actually
circumventing all the relevant logic in valac.  Autotools just uses
valac -C to convert the vala to C then proceeds with the rest of the
process exactly the same as with C, so you need to add any relevant
CFLAGS and LDFLAGS just as you would for a C project.  See
http://code.google.com/p/bump/source/browse/bump/Makefile.am#94 for an
example.

* Why it works on my computer? I check my Makefile,
  and there is no -lm.

I seem to remember that on certain platforms math functions are included
in libc and adding libm isn't necessary.  It's probably not a good idea
to rely on that and either always pass -lm or use AC_CHECK_LIB (or
something similar) to find out whether or not you need it.


-Evan




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