Thank you for your reply.
First I try "R CMD INSTALL barpkg", then it gives similiar things:
---------------------------------------------------------------------------------------------------------------------------------------------
* installing *source* package 'barpkg' ...
** libs
*** arch - i386
cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-31~1.0/etc/i386/Makeconf
Preferred POSIX equivalent is:
/cygdrive/c/PROGRA~1/R/R-31~1.0/etc/i386/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this
warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gfortran -m32 -O3 -mtune=core2 -c bar.f -o bar.o
gcc -m32 -shared -s -static-libgcc -o barpkg.dll tmp.def bar.o
-Ld:/RCompile/CRANpkg/extralibs64/local/lib/i386
-Ld:/RCompile/CRANpkg/extralibs64/local/lib -lgfortran
-LC:/PROGRA~1/R/R-31~1.0/bin/i386 -lR
cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-31~1.0/etc/i386/Makeconf
Preferred POSIX equivalent is:
/cygdrive/c/PROGRA~1/R/R-31~1.0/etc/i386/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this
warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
installing to C:/Users/emily/Desktop/rtest/barpkg.Rcheck/barpkg/libs/i386
*** arch - x64
cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-31~1.0/etc/x64/Makeconf
Preferred POSIX equivalent is:
/cygdrive/c/PROGRA~1/R/R-31~1.0/etc/x64/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this
warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gfortran -m64 -O2 -mtune=core2 -c bar.f -o bar.o
gcc -m64 -shared -s -static-libgcc -o barpkg.dll tmp.def bar.o
-Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64
-Ld:/RCompile/CRANpkg/extralibs64/local/lib -lgfortran
-LC:/PROGRA~1/R/R-31~1.0/bin/x64 -lR
cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-31~1.0/etc/x64/Makeconf
Preferred POSIX equivalent is:
/cygdrive/c/PROGRA~1/R/R-31~1.0/etc/x64/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this
warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
installing to C:/Users/emily/Desktop/rtest/barpkg.Rcheck/barpkg/libs/x64
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object
'C:/Users/emily/Desktop/rtest/barpkg.Rcheck/barpkg/libs/i386/bar.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/emily/Desktop/rtest/barpkg.Rcheck/barpkg'
----------------------------------------------------------------------------------------------------------------------------------------------------
2) I don't know how to check the "compile" problem. I just try to
"dyn.load" the shared object in /src-i386 and /src-x64 in the package, and
they both work well.
I am guessing there is some error in the R language.
".First.lib"<-function(libname,pkgname){library.dynam("barpkg",pkgname,
libname)}
barfun<-function(n,x){
.Fortran("bar",as.integer(n),as.double(x))
}
package.skeleton(name="barpkg",list=c("barfun"))
I am not sure about this part. Can anyone give me some suggestion?
I appreciate that very much.
-Emily
On Mon, Jul 21, 2014 at 11:42 AM, Duncan Murdoch <[email protected]>
wrote:
> On 21/07/2014 12:10 PM, yiqun yang wrote:
>
>> Hello, all
>>
>> I am building a R package using Fortran source code. The Fortran code is a
>> subroutine. I can use "R CMD SHLIB bar.f -o bar.o" to create the shared
>> library. For the R package, I put the fortran file in the src/ and I use R
>> code as follows:
>>
>> ".First.lib"<-function(libname,pkgname){library.dynam("barpkg",pkgname,
>> libname)}
>> barfun<-function(n,x){
>> .Fortran("bar",as.integer(n),as.double(x))
>> }
>> package.skeleton(name="barpkg",list=c("barfun"))
>> ------------------------------------------------------------
>> --------------
>> I can build with "R CMD build barpkg", when I check the package with "R
>> CMD
>> check barpkg", there is an error,
>>
>> ** R
>> ** preparing package for lazy loading
>> ** help
>> *** installing help indices
>> ** building package indices
>> ** testing if installed package can be loaded
>> *** arch - i386
>> Error in inDL(x, as.logical(local), as.logical(now), ...) :
>> unable to load shared object
>> 'c:/Users/emily/Desktop/rtest/barpkg.Rcheck/barpkg/libs/i386/bar.dll':
>> LoadLibrary failure: %1 is not a valid Win32 application.
>>
>
> You will see more information in the files in the barpkg.Rcheck directory
> created during the check. You can see some of those messages on the screen
> if you do an explicit INSTALL.
>
> I'd guess that the compile failed, but can't guess why.
>
> Duncan Murdoch
>
>
>
>> Error: loading failed
>> Execution halted
>> *** arch - x64
>> ERROR: loading failed for 'i386'
>>
>> I don't know how to fix this error. Can anyone help me with this?
>>
>> Thanks.
>> -Emily
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [email protected] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
>
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel