Hi there, Thank you all for your timely response. I find the right way to do it. There is a good example in Dr. Burns website: http://www.burns-stat.com/pages/Spoetry/Spoetry.pdf Page 174. So this is the right way to do: #include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> double test(double alpha) { double value; value = alpha *3; return(value); } void main2(double *alpha, double *beta) { double test(double); *beta= *alpha *2 + test(*alpha); } After compiling it by MINGW, you can use the following code in R: dyn.load("c:/Program Files/R/rw1060/bin/main2.dll") a=4.2 b=0 c=.C('main2', as.double(a), as.double(b))[[2]] Hope this helps! Sincerely, Lei Liu