gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 7e8c6b5: Installation: check for the C math li


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 7e8c6b5: Installation: check for the C math library before all others
Date: Sat, 13 Feb 2021 15:10:18 -0500 (EST)

branch: master
commit 7e8c6b550d8837c564d52c8ae3413a83963ee152
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Installation: check for the C math library before all others
    
    In the previous commit (which corrected the finding of linking flags at
    configure time), I had removed the check for the C Math library because the
    'AC_LIB_HAVE_LINKFLAGS' would add '-lm' in the check for GSL. However, on
    an Ubuntu system, we just discovered a crash because of not being able to
    link with the Math library.
    
    With this commit the check for the Math library and the addition of its
    flag has been re-introduced.
    
    On a minor note in the build on the Ubuntu, we also found a simple compiler
    warning about the possibility of being used uninitialized (which would
    never happen). But to supress the warning, the variable (a pointer to a
    function) has been initialized to NULL.
    
    This issue was reported by Zahra Sharbaf.
---
 bin/table/arithmetic.c       |  2 +-
 configure.ac                 | 11 +++++++++--
 doc/announce-acknowledge.txt |  1 +
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/bin/table/arithmetic.c b/bin/table/arithmetic.c
index 7ed41c6..809c318 100644
--- a/bin/table/arithmetic.c
+++ b/bin/table/arithmetic.c
@@ -512,7 +512,7 @@ arithmetic_distance(struct tableparams *p, gal_data_t 
**stack, int operator)
   double *o, *a1, *a2, *b1, *b2;
   gal_data_t *a, *b, *tmp, *out;
   char *colname=NULL, *colcomment=NULL;
-  double (*distance_func)(double, double, double, double);
+  double (*distance_func)(double, double, double, double)=NULL;
 
   /* Pop the columns for point 'b'.*/
   tmp=arithmetic_stack_pop(stack, operator, NULL);
diff --git a/configure.ac b/configure.ac
index 70f9433..78a8f30 100644
--- a/configure.ac
+++ b/configure.ac
@@ -284,8 +284,15 @@ orig_LIBS="$LIBS"
 # Start of library linking list
 # -----------------------------
 #
-# Note that 'AC_LIB_HAVE_LINKFLAGS' automatically links with the math
-# library ('-lm').
+# We'll start with the C math library (for things like 'log'). Even though
+# '-lm' is also found for GSL below, on some systems (reported on Ubuntu),
+# if we don't add it explicitly here, the build will crash because of a
+# failure to link with the math functions.
+AC_LIB_HAVE_LINKFLAGS([m], [], [#include <math.h>])
+AS_IF([test "x$LIBM" = x], [],
+      [LDADD="$LIBM $LDADD"; LIBS="$LIBM $LIBS"])
+
+
 AC_LIB_HAVE_LINKFLAGS([gsl], [gslcblas], [
 #include <gsl/gsl_rng.h>
 void junk(void) { gsl_rng_env_setup(); } ])
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 48fa070..2aff751 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -4,6 +4,7 @@ Mark Calabretta
 Raul Infante-Sainz
 Sylvain Mottet
 Francois Ochsenbein
+Zahra Sharbaf
 
 
 



reply via email to

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