Do you have the tools ? What operating system are you using ? What happens if you do this:

> code <- '#include <Rdefines.h>\nSEXP f(){\n return R_NilValue ; }'
> writeLines( code, "test.c" )
> system( "R CMD SHLIB test.c" )
> dyn.load( "test.so" )
> .Call( "f" )

Romain

Le 08/04/10 20:28, satu a écrit :


All is done in R 2.10.1 wiht the package "inline" version 0.3.4,,,
this are the packages that I have loaded into the workspace
search()
  [1] ".GlobalEnv"        "package:inline"    "package:stats"
"package:graphics"  "package:grDevices" "package:datasets"  "package:rcom"
  [8] "package:rscproxy"  "package:utils"     "package:methods"   "Autoloads"
"package:base"

This is pure copy and paste from the PDF file

x<- as.numeric(1:10)
n<- as.integer(10)
x
  [1]  1  2  3  4  5  6  7  8  9 10
n
[1] 10
sigSq<- signature(n="integer", x="numeric")
codeSq<- "
+ for (int i=0; i<  *n; i++) {
+ x[i] = x[i]*x[i];
+ }"
sigSq
         n         x
"integer" "numeric"
codeSq
[1] "\nfor (int i=0; i<  *n; i++) {\nx[i] = x[i]*x[i];\n}"
sigQd<- signature(n="integer", x="numeric")
codeQd<- "
+ squarefn(n, x);
+ squarefn(n, x);
+ "
sigQd
         n         x
"integer" "numeric"
codeQd
[1] "\nsquarefn(n, x);\nsquarefn(n, x);\n"
fns<- cfunction( list(squarefn=sigSq, quadfn=sigQd),
+ list(codeSq, codeQd),
+ convention=".C")

ERROR(s) during compilation: source code errors or compiler configuration
errors!

Program source:
   1: #include<R.h>
   2:
   3:
   4: extern "C" {
   5:   void squarefn ( int * n, double * x );
   6: }
   7:
   8: void squarefn ( int * n, double * x ) {
   9:
  10: for (int i=0; i<  *n; i++) {
  11: x[i] = x[i]*x[i];
  12: }
  13: }
  14: extern "C" {
  15:   void quadfn ( int * n, double * x );
  16: }
  17:
  18: void quadfn ( int * n, double * x ) {
  19:
  20: squarefn(n, x);
  21: squarefn(n, x);
  22:
  23: }
Error in compileCode(f, code, language, verbose) :
   Compilation ERROR, function(s)/method(s) not created!

Following the example shown in this PDF,,, after the fns<- cfunction( ,,, )
follows:

squarefn<- fns[["squarefn"]]
quadfn<- fns[["quadfn"]]
squarefn(n, x)$x
quadfn(n, x)$x

but the compile error shows up right after the cfunction(,,,) sentence.




--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9aKDM9 : embed images in Rd documents
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to