I would like to call C code from R. My C code is divided in two files. In the file "testpermut.c", I have the following lines:
#include "adesub.h"
In my working folder, I have the files: - adesub.c which contains general functions - adesub.h with the header of functions contained in adesub.c - testpermut.c which call some functions defined in adesub.c
When I try to create my dll (Work on Windows XP, R-1.8.1), I obtain error message:
$ Rcmd shlib testpermut.c
making adesub.d from adesub.c
making testpermut.d from testpermut.c
gcc -Ic:/Rdev/R-1.8.1/src/include -Wall -O2 -c testpermut.c -o testpermut.o
ar cr testpermut.a *.o
ranlib testpermut.a
gcc --shared -s -o testpermut.dll testpermut.def testpermut.a -Lc:/Rdev/R-1.8
.1/src/gnuwin32 -lg2c -lR
testpermut.a(testpermut.o.b)(.text+0x35):testpermut.c: undefined reference to `taballoc'
testpermut.a(testpermut.o.b)(.text+0x49):testpermut.c: undefined reference to `taballoc'
testpermut.a(testpermut.o.b)(.text+0x62):testpermut.c: undefined reference to `taballoc'
testpermut.a(testpermut.o.b)(.text+0x14c):testpermut.c: undefined reference to `freetab'
testpermut.a(testpermut.o.b)(.text+0x156):testpermut.c: undefined reference to `freetab'
testpermut.a(testpermut.o.b)(.text+0x160):testpermut.c: undefined reference to `freetab'
testpermut.a(testpermut.o.b)(.text+0x192):testpermut.c: undefined reference to `taballoc'
testpermut.a(testpermut.o.b)(.text+0x22b):testpermut.c: undefined reference to `taballoc'
testpermut.a(testpermut.o.b)(.text+0x23f):testpermut.c: undefined reference to `vecalloc'
testpermut.a(testpermut.o.b)(.text+0x24b):testpermut.c: undefined reference to `vecalloc'
testpermut.a(testpermut.o.b)(.text+0x339):testpermut.c: undefined reference to `freevec'
testpermut.a(testpermut.o.b)(.text+0x343):testpermut.c: undefined reference to `freevec'
testpermut.a(testpermut.o.b)(.text+0x34d):testpermut.c: undefined reference to `freetab'
testpermut.a(testpermut.o.b)(.text+0x412):testpermut.c: undefined reference to `taballoc'
make: *** [testpermut.dll] Error 1
$
The functions taballoc, freetab, vecalloc and freevec are defined in adesub files. So it seems that gcc does not make the links between my files. If I include the problematic functions in testpermut.c, gcc works perfectly and my dll is created.
Perhaps someone could explain me what is my problem although it is not an R problem but probably a misuse of gcc ?.
Thanks in advance.
St�phane DRAY
--------------------------------------------------------------------------------------------------
D�partement des Sciences Biologiques Universit� de Montr�al, C.P. 6128, succursale centre-ville Montr�al, Qu�bec H3C 3J7, Canada
Tel : 514 343 6111 poste 1233
E-mail : [EMAIL PROTECTED]
--------------------------------------------------------------------------------------------------
Web http://www.steph280.freesurf.fr/
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
