Dear R-masters, I tried to compile this simpel C-code: //----------------- #include<R.h> int main() { GetRNGstate(); return 0; } //----------------- Compiling: ~> gcc -o a a.c -I/usr/lib/R/include/ -L/usr/lib/R/bin/ -lR ~> ldd a libR.so => /usr/lib/libR.so (0x40018000) libc.so.6 => /lib/libc.so.6 (0x401a8000) libblas.so.2 => /usr/lib/libblas.so.2 (0x402bb000) libreadline.so.4 => /lib/libreadline.so.4 (0x4031e000) libdl.so.2 => /lib/libdl.so.2 (0x40347000) libncurses.so.5 => /lib/libncurses.so.5 (0x4034a000) libm.so.6 => /lib/libm.so.6 (0x40389000) libz.so.1 => /usr/lib/libz.so.1 (0x403ab000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) ~> ./a Segmentation fault Where am I wrong? I'm using R 1.6.1, glibc-2.3.1 on Debian woody system. Thanks a lot! -- WBR, Timur.
ripley@stats.ox.ac.uk
2002-Dec-20 18:00 UTC
[R] GetRNGstate() crashes with 'Segmentation fault'
Whyever do you think that should work? If you want to link against libR.so and call into R, you do need to initialize R, and you have not done so. I also don't see that the program has any use. The complicated ways to manipulate the random number generator are really only of any use from R code (via C code, perhaps). On Fri, 20 Dec 2002, Timur Elzhov wrote:> Dear R-masters, > > > I tried to compile this simpel C-code: > > //----------------- > > #include<R.h> > > int main() > { > GetRNGstate(); > return 0; > } > > //----------------- > > Compiling: > > ~> gcc -o a a.c -I/usr/lib/R/include/ -L/usr/lib/R/bin/ -lR > ~> ldd a > libR.so => /usr/lib/libR.so (0x40018000) > libc.so.6 => /lib/libc.so.6 (0x401a8000) > libblas.so.2 => /usr/lib/libblas.so.2 (0x402bb000) > libreadline.so.4 => /lib/libreadline.so.4 (0x4031e000) > libdl.so.2 => /lib/libdl.so.2 (0x40347000) > libncurses.so.5 => /lib/libncurses.so.5 (0x4034a000) > libm.so.6 => /lib/libm.so.6 (0x40389000) > libz.so.1 => /usr/lib/libz.so.1 (0x403ab000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) > > ~> ./a > Segmentation fault > > > Where am I wrong? > I'm using R 1.6.1, glibc-2.3.1 on Debian woody system. > > Thanks a lot! > > -- > WBR, > Timur. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595