Mark Clements
2023-Feb-14 13:37 UTC
[R] Issue with Rmath standalone (dwilcox, pwilcox, qwilcox, rwilcox) with unif_rand()
I may have found a bug in the Rmath standalone library when providing a user-defined random number generator (for context, I was investigating using Mersenne Twister with Rmath). The following C code does not compile using the Makefile: // test_fails.c #define MATHLIB_STANDALONE #include <Rmath.h> #include <stdio.h> double unif_rand(void) { return 0.5; } int main() { printf("%f\n", runif(0, 1)); printf("%f\n", pnorm(1.96, 0, 1, 1, 0)); printf("%f\n", dwilcox(100, 10, 20, 0)); return 0; } // Makefile LIBRMATH_A = $(shell pkg-config --variable=libdir libRmath)/libRmath.a test_fails: ??????gcc -o test_fails test_fails.c ${LIBRMATH_A} -lm The error is "multiple definition of `unif_rand'". The code compiles and runs correctly after commenting out either (a) the unif_rand function or (b) the call to dwilcox(). I found similar issues with pwilcox, qwilcox and rwilcox. Can anyone explain this behaviour, please? Sincerely, Mark. N?r du skickar e-post till Karolinska Institutet (KI) inneb?r detta att KI kommer att behandla dina personuppgifter. H?r finns information om hur KI behandlar personuppgifter<https://ki.se/medarbetare/integritetsskyddspolicy>. Sending email to Karolinska Institutet (KI) will result in KI processing your personal data. You can read more about KI?s processing of personal data here<https://ki.se/en/staff/data-protection-policy>.