From ojohnson at progress.com  Wed Jan 30 19:23:56 2008
From: ojohnson at progress.com (Oran Johnson)
Date: Wed, 30 Jan 2008 13:23:56 -0500
Subject: [Rd] The standalone Rmath library and VC++ 2003
In-Reply-To: <alpine.LFD.1.00.0801301754240.4291@gannet.stats.ox.ac.uk>
References: <427B18C08050B745B13ADA8EE5A99D9A019769FC@MAIL03.bedford.progress.com>
	<alpine.LFD.1.00.0801301754240.4291@gannet.stats.ox.ac.uk>
Message-ID: <427B18C08050B745B13ADA8EE5A99D9A01976C32@MAIL03.bedford.progress.com>

Yes, I used Rtools to compile the standalone Rmath library. However,
C:\Rtools\MinGW\lib\libm.a does not contain log1p;
C:\Rtools\MinGW\lib\libmingwex.a does. Once I replaced libm.a with
libmingwex.a, the application linked successfully and the following test
program was successful:

#include <iostream>
#define MATHLIB_STANDALONE
#include <Rmath.h>

int main()
{
	double d = dbeta(0.5, 2.0, 3.0, 1); 
	double q = qbeta(0.5, 2.0, 3.0, 1, 0); 
	double p = pbeta(0.5, 2.0, 3.0, 1, 0); 
	double r = rbeta(0.5, 2.0);

	std::cout << "dbeta = " << d << "\n";
	std::cout << "qbeta = " << q << "\n"; 
	std::cout << "pbeta = " << p << "\n";
	std::cout << "rbeta = " << r << "\n"; 
}


dbeta = 0.405465
qbeta = 0.385728
pbeta = 0.6875
rbeta = 0.422286
Press any key to continue

Thanks
Oran

-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] 
Sent: Wednesday, January 30, 2008 1:06 PM
To: Oran Johnson
Cc: r-devel at r-project.org
Subject: Re: [Rd] The standalone Rmath library and VC++ 2003

On Tue, 29 Jan 2008, Oran Johnson wrote:

> Linking my VC++ application with the standalone Rmath library yields
the
> following;

Looks like you compiled the standalone Rmath library with MinGW.  You 
can't expect to mix-and-match compilers and link together a static
library 
built under another compiler.

It is possible that this will work if you try linking to Rmath.dll: 
WIndows' DLLs are fairly portable (although parameter passing
conventions 
do differ, and we know 'double complex' is not portable).  I assume you 
know how to make a VC++ import library from a DLL, which you would need
to 
do.

If you compiled standalone Rmath under VC++, you would not have got a .a

but a lib, at least by default.  You are welcome to try that: it has
been 
done in the past but is not something we support (nor even would want to

answer questions about).


> ------ Build started: Project: Complex plugin, Configuration: Debug
> Win32 ------
>
>
>
> Linking...
>
>   Creating library .\../Debug/complex_plugin.lib and object
> .\../Debug/complex_plugin.exp
>
> libRmath.a(mlutils.o) : warning LNK4217: locally defined symbol __iob
> imported in function _REprintf
>
> libRmath.a(dbeta.o) : error LNK2019: unresolved external symbol _log1p
> referenced in function _dbeta
>
> libRmath.a(qbeta.o) : error LNK2019: unresolved external symbol _log1p
> referenced in function _qbeta
>
> libRmath.a(lbeta.o) : error LNK2019: unresolved external symbol _log1p
> referenced in function _lbeta
>
> libRmath.a(toms708.o) : error LNK2001: unresolved external symbol
_log1p
>
> libRmath.a(qbeta.o) : error LNK2019: unresolved external symbol _expm1
> referenced in function _qbeta
>
> libRmath.a(mlutils.o) : error LNK2019: unresolved external symbol
> ___fpclassify referenced in function _R_pow
>
> ../Debug/complex_plugin.dll : fatal error LNK1120: 3 unresolved
> externals
>
>
>
> Build log was saved at "file://c:\starting point\Debug\BuildLog.htm"
>
> Complex plugin - 7 error(s), 1 warning(s)
>
>
>
>
>
> ---------------------- Done ----------------------
>
>
>
>    Build: 0 succeeded, 1 failed, 0 skipped
>
>
>
> At first glance, it looks like C:\Rtools\MinGW\lib\libm.a is missing.
> After adding it to my project properties, the results are the same. It
> looks like VC++ is OK with GNU libraries because it appears to accept
> libRmath which was built on the same machine using Rtools. Also it
does
> not appear to be a configuration issue, because it's only found
> 'C:\Rtools\MinGW\lib' and VC+ is complaining about not finding it.
>
>
>
> Any ideas?
>
>
>
> Oran
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] The standalone Rmath library and VC++ 2003
Oran Johnson