Hadassa, On 11 January 2009 at 15:29, Hadassa Brunschwig wrote: | Again, I am trying to include a C function tools.c into a main.c file | which needs to be run via R. | I include the header file via #include tools.h . | What I understood is that I need another file which specifically links | the header file | with the tools.c files (or .o file?). My questions are thus: | | 1. Can I just create a file Makevars with the variable | PKG_LIBS=-L/directory_of_tools -l/tools?
Yes... | 2. Does this file need to be located in the same directory as main.c? Yes... | 3. When I then run the command R CMD SHLIB it does not make use of | Makevars. So what do I need to add? ... but Makevars is for R package building. See the 'R Extensions' manual for documentation, and literally hundreds of packages on CRAN for live examples to look at _in source_ on how to link C code to R code. | 4. Does tools.c need to be a shared object as well? tools.c is source code, tools.o would be object code. If you want to dynamically load it, then it needs to be a shared object too. Worked examples are also in my 'introduction to high-performance computing with R' slides from August and December. It covers added compiled code to R on a few slides with worked examples using the inline and Rcpp packages. Dirk -- Three out of two people have difficulties with fractions. ______________________________________________ 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.