[Home]

Summary:ASTERISK-11307: configure does not find floor, pow, rint, sqrt in tgmath.h
Reporter:pbwolf (pbwolf)Labels:
Date Opened:2008-01-25 20:55:55.000-0600Date Closed:2011-06-07 14:08:14
Priority:MinorRegression?No
Status:Closed/CompleteComponents:General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:configure is not finding floor, pow, rint, or sqrt.

checking for floor... no
checking for pow... no
checking for rint... no
checking for sqrt... no

But they're there:

$ egrep -w "#define (floor|pow|rint|sqrt)" /usr/include/*.h
/usr/include/tgmath.h:#define pow(Val1, Val2) __TGMATH_BINARY_REAL_IMAG (Val1, Val2, pow, cpow)
/usr/include/tgmath.h:#define sqrt(Val) __TGMATH_UNARY_REAL_IMAG (Val, sqrt, csqrt)
/usr/include/tgmath.h:#define floor(Val) __TGMATH_UNARY_REAL_ONLY (Val, floor)
/usr/include/tgmath.h:#define rint(Val) __TGMATH_UNARY_REAL_ONLY (Val, rint)


****** ADDITIONAL INFORMATION ******

$ uname -srmpi
Linux 2.6.23.9-85.fc8 x86_64 x86_64 x86_64

The compiler:

$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)
Comments:By: Tilghman Lesher (tilghman) 2008-01-26 19:02:11.000-0600

The check has nothing to do with whether it can be found in a header file, but rather whether the function actually exists in a library file.  If it's not finding it in the libm.so library, then your installation is out of spec with the Linux standard.  Complain to your OS vendor that they screwed the pooch.

See 'man pow' for details.

By: pbwolf (pbwolf) 2008-01-27 09:49:55.000-0600

gcc -lm seems to find libm:

$ cat m.c
#include <stdio.h>
#include <math.h>
int main(char** argv) {
 double off_the_floor = 4.5;
 printf("floor(%lf)=%lf.\n", off_the_floor, floor(off_the_floor));
 return 0;
}

$ gcc -lm m.c
$ ./a.out
floor(4.500000)=4.000000.

(Without the -lm, gcc says "undefined reference to `floor'", as expected.)

By: pbwolf (pbwolf) 2008-02-03 15:24:32.000-0600

Here is a snippet from config.log.  The problem might be that configure is not using -lm.  Recompiling the "failed program" with the same gcc command line, plus -lm, works:

$ gcc -o conftest -g -O2 -lm conftest.c  &&  echo ok
a.c:132: warning: conflicting types for built-in function ‘sqrt’
ok



configure:14812: checking for sqrt
configure:14868: gcc -o conftest -g -O2   conftest.c  >&5
conftest.c:132: warning: conflicting types for built-in function 'sqrt'
/tmp/ccyxGR7J.o: In function `main':
/home/pbwolf/phones/asterisk14/conftest.c:143: undefined reference to `sqrt'
collect2: ld returned 1 exit status
configure:14874: $? = 1
configure: failed program was:
| /* confdefs.h.  */
| #define PACKAGE_NAME "asterisk"
| #define PACKAGE_TARNAME "asterisk"
| #define PACKAGE_VERSION "1.4"
| #define PACKAGE_STRING "asterisk 1.4"
| #define PACKAGE_BUGREPORT "www.asterisk.org"
| #define _GNU_SOURCE 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define __EXTENSIONS__ 1
| #define _POSIX_PTHREAD_SEMANTICS 1
| #define _TANDEM_SOURCE 1
| #define HAVE_PTHREAD 1
| #define HAVE_ALLOCA_H 1
| #define HAVE_ALLOCA 1
| #define HAVE_DIRENT_H 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_WAIT_H 1
| #define HAVE_ARPA_INET_H 1
| #define HAVE_FCNTL_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_LIBINTL_H 1
| #define HAVE_LIMITS_H 1
| #define HAVE_LOCALE_H 1
| #define HAVE_MALLOC_H 1
| #define HAVE_NETDB_H 1
| #define HAVE_NETINET_IN_H 1
| #define HAVE_STDDEF_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_SYS_FILE_H 1
| #define HAVE_SYS_IOCTL_H 1
| #define HAVE_SYS_PARAM_H 1
| #define HAVE_SYS_SOCKET_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_SYSLOG_H 1
| #define HAVE_TERMIOS_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_UTIME_H 1
| #define HAVE__BOOL 1
| #define HAVE_STDBOOL_H 1
| #define HAVE_STRUCT_STAT_ST_BLKSIZE 1
| #define TIME_WITH_SYS_TIME 1
| #define HAVE_PTRDIFF_T 1
| #define HAVE_UNISTD_H 1
| #define HAVE_CHOWN 1
| #define HAVE_FORK 1
| #define HAVE_VFORK 1
| #define HAVE_WORKING_VFORK 1
| #define HAVE_WORKING_FORK 1
| #define HAVE_FSEEKO 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_UTIME_H 1
| #define HAVE_ALARM 1
| #define HAVE_STDLIB_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_GETPAGESIZE 1
| #define HAVE_MMAP 1
| #define HAVE_SYS_SELECT_H 1
| #define HAVE_SYS_SOCKET_H 1
| #define SELECT_TYPE_ARG1 int
| #define SELECT_TYPE_ARG234 (fd_set *)
| #define SELECT_TYPE_ARG5 (struct timeval *)
| #define PROTOTYPES 1
| #define __PROTOTYPES 1
| #define RETSIGTYPE void
| #define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
| #define HAVE_STRCOLL 1
| #define HAVE_STRFTIME 1
| #define HAVE_UTIME_NULL 1
| #define HAVE_VPRINTF 1
| #define HAVE_ASPRINTF 1
| #define HAVE_ATEXIT 1
| #define HAVE_BZERO 1
| #define HAVE_DUP2 1
| #define HAVE_ENDPWENT 1
| #define HAVE_FTRUNCATE 1
| #define HAVE_GETCWD 1
| #define HAVE_GETHOSTBYNAME 1
| #define HAVE_GETHOSTNAME 1
| #define HAVE_GETLOADAVG 1
| #define HAVE_GETTIMEOFDAY 1
| #define HAVE_INET_NTOA 1
| #define HAVE_ISASCII 1
| #define HAVE_LOCALTIME_R 1
| #define HAVE_MEMCHR 1
| #define HAVE_MEMMOVE 1
| #define HAVE_MEMSET 1
| #define HAVE_MKDIR 1
| #define HAVE_MUNMAP 1
| #define HAVE_PUTENV 1
| #define HAVE_RE_COMP 1
| #define HAVE_REGCOMP 1
| #define HAVE_SELECT 1
| #define HAVE_SETENV 1
| #define HAVE_SOCKET 1
| /* end confdefs.h.  */
| /* Define sqrt to an innocuous variant, in case <limits.h> declares sqrt.
|    For example, HP-UX 11i <limits.h> declares gettimeofday.  */
| #define sqrt innocuous_sqrt
|
| /* System header to define __stub macros and hopefully few prototypes,
|     which can conflict with char sqrt (); below.
|     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
|     <limits.h> exists even on freestanding compilers.  */
|
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
|
| #undef sqrt
|
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char sqrt ();
| /* The GNU C library defines this for functions which it implements
|     to always fail with ENOSYS.  Some functions are actually named
|     something starting with __ and the normal name is an alias.  */
| #if defined __stub_sqrt || defined __stub___sqrt
| choke me
| #endif
|
| int
| main ()
| {
| return sqrt ();
|   ;
|   return 0;
| }
configure:14892: result: no

By: Tilghman Lesher (tilghman) 2008-02-06 12:36:17.000-0600

The warnings are innocuous.  We don't actually do anything with any of those defines in 1.4 anyway.  This has already been fixed in trunk.