Skip to content

write R extenesion issue

9 messages · jiesheng zhang, Duncan Murdoch, Peter Dalgaard +1 more

#
Hi, all
I am trying to write a R package. I was able to build and install the 
package with no problem.
However, I got this error when I try to load the library by calling 
library("btRRTest");
------------------error message in loading---------
 > library("btRRTest")
Error in library("btRRTest") : 'btRRTest' is not a valid package -- 
installed < 2.0.0?
---------------------------------
--------build message-----------
ason at jasonportal:~/tmp2> R CMD build --force btRRTest
* checking for file 'btRRTest/DESCRIPTION' ... OK
* preparing 'btRRTest':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking whether 'INDEX' is up-to-date ... NO
* overwriting 'INDEX' as '--force' was given
* removing junk files
* checking for LF line-endings in source files
* checking for empty directories
* building 'btRRTest_0.0.1.tar.gz'
---------------------------------
-------install message-------
jasonportal:/home/jason/tmp2 # R CMD INSTALL btRRTest_0.0.1.tar.gz
* Installing *binary* package 'btRRTest' ...
* DONE (btRRTest)
----------------------


Can anyone tell me what are the possible causes for this error? Where 
should I start to look?

Thanks

-jason
#
My package structure is very simple.
I attached it here.
Any help is appreciated.
-ason
jiesheng zhang wrote:
#
I found my attachment was discarded.
My R package structure lis listed here
-----------------------------
btRRTest
	DESCRIPTION
		Package: btRRTest
		Version: 0.0.1
		Date: 2005-10-15
		Title: a test remote R exeuction
		Author: jiesheng at bioteam.net
		Maintainer: jason zhang<jiesheng at bioteam.net>
		Depends: R (>= 1.8.0)
		Description: the remote execution of R call
		License: GPL version 2
		URL: http://www.bioteam.net
		Built: R 2.1.1; i686-pc-linux-gnu; 2005-09-20 00:07:19; unix
		Packaged: Sat Oct 15 23:42:11 2005; root
	INDEX
		btRRTestOut             serialize all
		btRRTestInt             unserialize all and execute
	R/btRRTest.R
		.First.lib <- function (lib, pkg)
		{
		    #library.dynam("btRRTest", pkg, lib)
		    print(c("first.lib", pkg, lib))
		}

		btRRTestOut<-function(x)
		{
         		#.Call("btRRTestOut", substitute(x), rho=sys.frame(-1), 
PACKAGE="btRRTest");
         		print("btRRTestOut");
		}

		btRRTestIn<-function()
		{
         		#.Call("btRRTestIn",  PACKAGE="btRRTest");
         		print("btRRTestIn");
		}

----------------------------

-jason
jiesheng zhang wrote:
#
jiesheng zhang wrote:
Is this from your source directory?  You shouldn't have the Built and 
Packaged lines in your source.

If this is from the directory where it was installed, never mind, unless 
those two directories are the same:  in which case the advice is "don't 
do that".  Keep your installed copies separate from the source.

The error message you saw
indicates that the "Meta/package.rds" file is missing from your 
installed package subdirectory, but it's hard to guess why.

Duncan Murdoch
#
jiesheng zhang <jiesheng at bioteam.net> writes:
I don't think you want to have a Built: field in a source package.
Apparently, you are getting the package installed as a binary package
even though it isn't.

  
    
#
Here is the cause:
^^^^^^

However, you have a source package, and you have an invalid DESCRIPTION 
file containing a Built: line.

Please read `Writing R Extensions' and check you are following the rules 
it lays down (as in this respect at least you are not).
On Sat, 15 Oct 2005, jiesheng zhang wrote:

            

  
    
#
Hi, duncan
I remove the built and packaged line from DESCRIPTION and install from 
source. It worked right now

Thanks
-jason
Duncan Murdoch wrote:
#
Hi, all

I am in the process of writing my first R extesion package.

One of my function uses StrToInternal function(I copy it from other 
extension package). I noticed the StrToInternal was defined in "Defn.h". 
I have two questions:
1)should "Defn.h"  be under $R_HOME/include. I could not find it in any 
file under $R_HOME/include.
2)Where is the implementation for the functions defined in the "Defn.h"? 
Where dynamic library should I link to for the StrToInternal implementation?

When I load my extension and library, I got this error
-------------------------------
 > library("btRRTest")
Error in dyn.load(x, as.logical(local), as.logical(now)) :
         unable to load shared library 
'/common/apps/lib/R/library/btRRTest/libs/btRRTest.so':
   /common/apps/lib/R/library/btRRTest/libs/btRRTest.so: undefined 
symbol: StrToInternal
Error in library("btRRTest") : .First.lib failed for 'btRRTest'
--------------------------------

My package is compiled during installation like this
--------------------------------
jasonportal:/home/jason/tmp2 # R CMD INSTALL btRRTest
* Installing *source* package 'btRRTest' ...
** libs
gcc -I/common/apps/lib/R/include  -I/usr/local/include   -fPIC  -g -O2 
-c btRRtest.c -o btRRtest.o
gcc -I/common/apps/lib/R/include  -I/usr/local/include   -fPIC  -g -O2 
-c client.c -o client.o
gcc -I/common/apps/lib/R/include  -I/usr/local/include   -fPIC  -g -O2 
-c pack.c -o pack.o
gcc -I/common/apps/lib/R/include  -I/usr/local/include   -fPIC  -g -O2 
-c rpack.c -o rpack.o
rpack.c: In function `my_remove':
rpack.c:23: warning: assignment makes pointer from integer without a cast
rpack.c: In function `CreateDataPacket':
rpack.c:156: warning: assignment makes pointer from integer without a cast
rpack.c: In function `convertDataPacketToVariable':
rpack.c:229: warning: assignment makes pointer from integer without a cast
rpack.c: In function `setDataPacketToEnv':
rpack.c:256: warning: assignment makes pointer from integer without a cast
gcc -I/common/apps/lib/R/include  -I/usr/local/include   -fPIC  -g -O2 
-c util.c -o util.o
gcc -I/common/apps/lib/R/include  -I/usr/local/include   -fPIC  -g -O2 
-c worker.c -o worker.o
gcc -shared -L/usr/local/lib -o btRRTest.so btRRtest.o client.o pack.o 
rpack.o util.o worker.o
** R
No man pages found in package 'btRRTest'
** building package indices ...
* DONE (btRRTest)
--------------------------------

Help is appreciated.

-jason
#
On Sun, 16 Oct 2005, jiesheng zhang wrote:

            
Have you read our posting guide?  Please ask C programming questions on 
the apppropriate list -- R-devel.

Have you read `Writing R Extensions'?  It does cover this topic with 
copious warnings against what you are asking to do.
Which package is that?  Please avoid copying from packages which use
internal headers (and they probably do not work).
No.  It is an internal header.  You could have read the Makefiles to see 
that it is not an exported header.
Almost always in src/main/*.c.
None, you should not be calling functions not documented in `Writing R 
Extensions', and you certainly should not be asking for technical support 
to do so.