From dmbates at gmail.com  Fri Aug 12 04:32:23 2005
From: dmbates at gmail.com (Douglas Bates)
Date: Thu, 11 Aug 2005 21:32:23 -0500
Subject: [Rd] include C functions from nmath in my own C functions
In-Reply-To: <20050811165213.56487.qmail@web53107.mail.yahoo.com>
References: <20050811165213.56487.qmail@web53107.mail.yahoo.com>
Message-ID: <40e66e0b0508111932f1b9f3e@mail.gmail.com>

On 8/11/05, yyan liu <zhliur at yahoo.com> wrote:
>  Hi:
>   I followed the README in src/nmath/standalone/
>  to make the use the command "make shared" to make the
>  libRmath.so file. I also add the directories containg
>  libRmath.so to  LD_LIBRARY_PATH by using command
>  "export
> D_LIBRARY_PATH=$LD_LIBRARY_PATH:$/home/zhliu/Backup/R-2.0.1/src/nmath/standalon
>     e
>  "
>  However, when I try to run the following codes by the
> command "gcc test.c -lRmath" on Linux Fedora Core 2,
>  /***********************************************/
> /* file name test.c */
>  #define MATHLIB_STANDALONE 1
>  #include <Rmath.h>
> 
>  int
>  main()
>  {
>  /* something to force the library to be included */
>     qnorm(0.7, 0.0, 1.0, 0, 0);
>     return 0;
>  }
>  /**************************************************/
> 
>  the compiler gives me the following error message. It
> seems definitions of some R functions can not be found
> in the libRmath.so file. Anyone has any idea about
> this
> problem? Thank you very much!
> 
> 
>  /usr/local/lib/libRmath.so: undefined reference to
>  `expm1'
>  /usr/local/lib/libRmath.so: undefined reference to
>  `log'
>  /usr/local/lib/libRmath.so: undefined reference to
>  `sqrt'
>  /usr/local/lib/libRmath.so: undefined reference to
>  `rint'
>  /usr/local/lib/libRmath.so: undefined reference to
>  `cos'
>  /usr/local/lib/libRmath.so: undefined reference to
>  `sin'
>  /usr/local/lib/libRmath.so: undefined reference to
>  `pow'
>  /usr/local/lib/libRmath.so: undefined reference to
>  `sinh'
>  /usr/local/lib/libRmath.so: undefined reference to
>  `log10'
>  /usr/local/lib/libRmath.so: undefined reference to
>  `exp'
>  /usr/local/lib/libRmath.so: undefined reference to
>  `tan'
>  /usr/local/lib/libRmath.so: undefined reference to
>  `log1p'
>  /usr/local/lib/libRmath.so: undefined reference to
>  `hypot'
>  collect2: ld returned 1 exit status
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

Add -lm to the end of the call to gcc.  You are missing functions from
the math library.



[Rd] include C functions from nmath in my own C functions
Douglas Bates