From dmurdoch at pair.com  Wed Feb 18 02:48:23 2004
From: dmurdoch at pair.com (Duncan Murdoch)
Date: Wed Feb 18 02:48:35 2004
Subject: [Rd]  RCMD SHLIB == Couldn't reserve space for cygwin's heap,
	Win32 ?
In-Reply-To: <006301c3f598$1c7b1b90$0a00a8c0@rodan>
References: <006301c3f598$1c7b1b90$0a00a8c0@rodan>
Message-ID: <jng530dau23bjg2g5c26bd9jj6q9fio3qu@4ax.com>

On Tue, 17 Feb 2004 12:53:35 -0800, you wrote:

>I've been trying to create/load/call a dll from R-1.8.1 on Windows without
>much success. I've been able to at least load the library on FreeBSD
>(1.8.1). I've been able to perform this before using DLL that weren't
>created using RCMD SHLIB, but simply compiling under MS DevStudio.
>
>
>C:\optflikam>rcmd shlib --output=optflikam.dll as47.f as197.f flikam.c
>g77 -O2 -Wall   -c as47.f -o as47.o
>as47.f: In subroutine `minim':
>as47.f:829: warning:
>        4  1X'RESIDUAL VARIANCE'/' TO OBTAIN THE COVARIANCE MATRIX.'/)
>             ^
>Missing comma in FORMAT statement at (^)
>as47.f:634: warning: `savemn' might be used uninitialized in this function
>as47.f: In subroutine `chola':
>as47.f:1040: warning: `w' might be used uninitialized in this function
>as47.f:1041: warning: `rsq' might be used uninitialized in this function
>as47.f:1043: warning: `i' might be used uninitialized in this function
>g77 -O2 -Wall   -c as197.f -o as197.o
>gcc   -Ic:/PROGRA~1/r/rw1081/src/include -Wall -O2   -c flikam.c -o flikam.o
>In file included from flikam.c:16:
>flikam.h:10:1: warning: "__stdcall" redefined

I'd worry about this warning:  stdcall is the name of a calling
convention, so this is likely some code being misinterpreted pretty
badly.

><built-in>:61:1: warning: this is the location of the previous definition
>flikam.h:169:8: warning: extra tokens at end of #endif directive
>flikam.c: In function `mainard':
>flikam.c:127: warning: implicit declaration of function `minim_'
>flikam.c:209: warning: implicit declaration of function `nelmin_'
>flikam.c: In function `minim_objfunc':
>flikam.c:293: warning: implicit declaration of function `flikam_'
>flikam.c: In function `testfunc':
>flikam.c:424: warning: passing arg 1 of `Rf_length' from incompatible
>pointer type

This also looks like trouble to me...


> Then from R, I've tried to simply load the library and R crashes and I
>can't load the DLL. I keep getting the following error:
>
>> dyn.load( "optflikam.dll" )
>      5 [main] ? 4012 init_cheap: Couldn't reserve space for cygwin's heap,
>Win32 error 487
>c:\program files\r\rw1081\bin\Rterm.exe (4012): *** AllocationBase 0x0,
>BaseAddress 0x61670000, RegionSize 0x1050000, State 0x10000

Your DLL expects to be running under Cygwin.  R doesn't run Cygwin; we
use the MinGW compiler.   DLLs produced by all sorts of other
compilers do work, so you might be able to get Cygwin to work if you
try hard enough -- but it's probably easier to install MinGW.  See
mingw.org for downloads, etc., and the readme.packages file in the
Windows installation for our recommended toolsets.

Duncan Murdoch


[Rd] RCMD SHLIB == Couldn't reserve space for cygwin's heap, Win32 ?
Duncan Murdoch