From murdoch at stats.uwo.ca  Fri Mar  6 01:51:50 2009
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Thu, 05 Mar 2009 19:51:50 -0500
Subject: [Rd] problem building a package with C code (PR#13572)
In-Reply-To: <20090305145505.2FC97283218F@mail.pubhealth.ku.dk>
References: <20090305145505.2FC97283218F@mail.pubhealth.ku.dk>
Message-ID: <49B073A6.4060005@stats.uwo.ca>

On 05/03/2009 9:55 AM, pfarina at mat.puc.cl wrote:
> Hi, my name is Paula. Im trying to learn how to build an R package in
> Windows XP using a simple example which includes a C source code. The
> foo.c file is located in mypkg/src/foo.c.
> 
> I used the command  Rcmd build --force --binary [pkgpath]. The problem is
> when I install the zip file in R the function foo doesn?t exist.
> 
> The result a recieved during the building process is copied below.
> 
> I really appreciate some help....I very new on it and I have spent a lot
> of time trying to solve the problem alone without success.

I'd guess you didn't load the dll.  See my useR2008 talk for the steps 
needed to produce a package containing C code.  It looks as though 
you're close.

Duncan Murdoch

> 
> Thanks a lot
> 
> Paula Fari?a
> 
> 
> C:\>cd C:\Archivos de programa\R\R-2.7.2\bin
> 
> C:\Archivos de programa\R\R-2.7.2\bin>Rcmd build --force --binary
> D:\2009\c2r\my
> pkg
> * checking for file 'D:\2009\c2r\mypkg/DESCRIPTION' ... OK
> * preparing 'D:\2009\c2r\mypkg':
> * checking DESCRIPTION meta-information ... OK
> * cleaning src
> * removing junk files
> * checking for LF line-endings in source and make files
>     file 'mypkg/src/foo.c' had non-LF line endings
> * checking for empty or unneeded directories
> * building binary distribution
> WARNING: some HTML links may not be found
> installing R.css in C:/DOCUME~1/Lir/CONFIG~1/Temp/Rinst96073413
> 
> Using auto-selected zip options ''
> 
> ---------- Making package mypkg ------------
>   adding build stamp to DESCRIPTION
>   making DLL ...
> making foo.d from foo.c
> gcc  -std=gnu99  -Ic:/ARCHIV~1/R/R-27~1.2/include     -O3 -Wall  -c foo.c
> -o foo
> .o
> windres --preprocessor="gcc -E -xc -DRC_INVOKED" -I
> c:/ARCHIV~1/R/R-27~1.2/inclu
> de  -i mypkg_res.rc -o mypkg_res.o
> gcc  -std=gnu99  -shared -s  -o mypkg.dll mypkg.def foo.o mypkg_res.o 
> -Lc:/ARCH
> IV~1/R/R-27~1.2/bin    -lR
>   ... DLL made
>   installing DLL
>   installing R files
>   installing data files
>   installing man source files
>   installing indices
>   not zipping data
>   installing help
>  >>> Building/Updating help pages for package 'mypkg'
>      Formats: text html latex example chm
>   d                                 text    html    latex   example chm
>   e                                 text    html    latex   example chm
>   f                                 text    html    latex   example chm
>   g                                 text    html    latex   example chm
>   mypkg-package                     text    html    latex   example chm
> Microsoft HTML Help Compiler 4.74.8702
> 
> Compiling c:\DOCUME~1\Lir\CONFIG~1\Temp\Rbuild96033789\mypkg\chm\mypkg.chm
> 
> 
> Compile time: 0 minutes, 2 seconds
> 6       Topics
> 11      Local links
> 0       Internet links
> 1       Graphic
> 
> 
> Created c:\DOCUME~1\Lir\CONFIG~1\Temp\Rbuild96033789\mypkg\chm\mypkg.chm,
> 18,792
>  bytes
> Compression increased file by 2,040 bytes.
>   adding MD5 sums
> 
> packaged installation of package 'mypkg' as mypkg_1.0.zip
> * DONE (mypkg)
> 
> 
> C:\Archivos de programa\R\R-2.7.2\bin>
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] problem building a package with C code (PR#13572)
Duncan Murdoch