Dear list; This might sound a bit naive, but then I am new to linking C DLL's to R. I have built a DLL using GCC and am able to load the DLL in R (is.loaded("contents")==TRUE). When I include it in my function it returns NaN for all the variables. My R function is, dyn.load("c:/data/tempdll.dll") is.loaded("contents")#returns TRUE # contents <- function(new.cases){ cases <- rep(0, length(new.cases)) case.times <- rep(0, length(new.cases)) temp <- .C("contents", as.integer(cases), as.double(case.times)) } and the header of my C function is #ifndef _DLL_H_ #define _DLL_H_ #if BUILDING_DLL # define DLLIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define DLLIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ DLLIMPORT void contents (int *cases, double *case_times); #endif /* _DLL_H_ */ and my C function is. #include <windows.h> #include <stdio.h> #include <stdlib.h> #include "dll.h" #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> void contents(int *cases, double *case_times) { gsl_rng * r; gsl_rng_env_setup(); r = gsl_rng_alloc (gsl_rng_default); int i; for(i = 0; i < 1000; i++) { cases[i] = gsl_ran_negative_binomial (r, 0.10/2.10, 0.10); case_times[i] = gsl_ran_weibull (r, 9, 5); } gsl_rng_free (r); } I am clueless as to where it all goes wrong, as if I make the program an executable it works. Thanks again. Vumani