[R] again question about nmath/standalone
xt_wang@cs.concordia.ca
xt_wang at cs.concordia.ca
Mon May 3 18:44:53 CEST 2004
Thanks every expert! I have fixed the problem that I can use R library in c
code right now.
However, it still has problem that I can not compile the c code. I attach the
operation process to this letter. Who is so kind to help me find where is the
problem? Thnaks in advance!
[credsim at confsys ~/src]$ gcc test1.c -o test1 -lRmath -lm
/tmp/ccYbnKy1.o(.text+0xd0): In function `main':
: undefined reference to `dim'
/tmp/ccYbnKy1.o(.text+0xdf): In function `main':
: undefined reference to `c'
/tmp/ccYbnKy1.o(.text+0xee): In function `main':
: undefined reference to `solve'
collect2: ld returned 1 exit status
test1.c code is as follow:
[credsim at confsys ~/src]$ vi test1.c
#define MATHLIB_STANDALONE
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include </usr/local/lib/R/include/Rmath.h>
main()
{
int i,j,I,J,n;
I=3;
J=3;
n=I*J;
double valin;
double x2[9];
FILE *in_file;
/* input x value from file data_2Dx.txt */
in_file=fopen("data_2Dx.txt","r");
if (in_file==NULL)
{/*Test for error*/
fprintf(stderr,"Error:Unable to input file
from 'data_2Dx.txt'\n");
exit(8);
}
for( i=0;i<n;i++)
/* for (j=0;j<J;j++)*/
{ fscanf(in_file, "%lf\n", &valin, stdin);/* read a single double
value in */
x2[i]=valin;
valin=0.0;
}
fclose(in_file);
dim(x2)<-c(3,3);
solve(x2);
return (0);
}
More information about the R-help
mailing list