[PATCH] examples: link mfcalc with -lm for uses of pow, cos, atan, etc.

View: New views
2 Messages — Rating Filter:   Alert me  

[PATCH] examples: link mfcalc with -lm for uses of pow, cos, atan, etc.

by Jim Meyering :: Rate this Message:

| View Threaded | Show Only this Message

Building from cloned sources, I got this:

...
gcc -std=gnu99 -Wall -Wextra -Wno-sign-compare -Wcast-align -Wcast-qual -Wformat
-Wpointer-arith -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmiss
ing-prototypes -Wshadow -Wstrict-prototypes -g -O2   -o examples/mfcalc/mfcalc ex
amples/mfcalc/examples_mfcalc_mfcalc-mfcalc.o lib/libbison.a
examples/mfcalc/examples_mfcalc_mfcalc-mfcalc.o: In function `yyparse':
/h/j/w/co/bison/../../doc/bison.texinfo:2419: undefined reference to `pow'
examples/mfcalc/examples_mfcalc_mfcalc-mfcalc.o:(.rodata+0x88): undefined reference to `atan'
examples/mfcalc/examples_mfcalc_mfcalc-mfcalc.o:(.rodata+0x98): undefined reference to `cos'
examples/mfcalc/examples_mfcalc_mfcalc-mfcalc.o:(.rodata+0xa8): undefined reference to `exp'
examples/mfcalc/examples_mfcalc_mfcalc-mfcalc.o:(.rodata+0xb8): undefined reference to `log'
examples/mfcalc/examples_mfcalc_mfcalc-mfcalc.o:(.rodata+0xc8): undefined reference to `sin'
examples/mfcalc/examples_mfcalc_mfcalc-mfcalc.o:(.rodata+0xd8): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
make[3]: *** [examples/mfcalc/mfcalc] Error 1
make[3]: *** Waiting for unfinished jobs....

Here's one way to fix it:

From cbef12deb94918d4f24286d498bcedba4938d6fa Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@...>
Date: Fri, 17 Feb 2012 08:36:57 +0100
Subject: [PATCH] examples: link mfcalc with -lm for uses of pow, cos, atan,
 etc.

* examples/mfcalc/local.mk (examples_mfcalc_mfcalc_LDADD): Define.
---
 examples/mfcalc/local.mk |    1 +
 1 file changed, 1 insertion(+)

diff --git a/examples/mfcalc/local.mk b/examples/mfcalc/local.mk
index aae9e04..e34d8d7 100644
--- a/examples/mfcalc/local.mk
+++ b/examples/mfcalc/local.mk
@@ -49,6 +49,7 @@ mfcalc_sources = \
   $(mfcalc_extracted)

 check_PROGRAMS += examples/mfcalc/mfcalc
+examples_mfcalc_mfcalc_LDADD = -lm
 examples_mfcalc_mfcalc_SOURCES = \
   $(mfcalc_sources)

--
1.7.9.1.232.g1a183


Parent Message unknown Re: [PATCH] examples: link mfcalc with -lm for uses of pow, cos, atan, etc.

by Akim Demaille :: Rate this Message:

| View Threaded | Show Only this Message


> Here's one way to fix it:
>
> From cbef12deb94918d4f24286d498bcedba4938d6fa Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering@...>
> Date: Fri, 17 Feb 2012 08:36:57 +0100
> Subject: [PATCH] examples: link mfcalc with -lm for uses of pow, cos, atan,
> etc.
>
> * examples/mfcalc/local.mk (examples_mfcalc_mfcalc_LDADD): Define.

Thanks, I installed it!