[m-users.] Error with static linking for the rmath library

Mark Clements <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <GV3P280MB000116DD3395F4447A062B41F0DF9@GV3P280MB0001.SWEP280.PROD.OUTLOOK.COM>
For the rmath library in Mercury (https://github.com/mclements/mercury-rmath), I am trying to use C code for the Mersenne Twister random number generator to replace the default random number generator. This involves replacing two C functions: double unif_rand(void) and void set_seed(unsigned int, unsigned int); for details, see https://rstudio.github.io/r-manuals/r-admin/The-standalone-Rmath-library.html.

I have got this working -- _except_ if any of four functions (dwilcox, pwilcox, qwilcox, rwilcox) are included in the interface section (see the gist at https://gist.github.com/mclements/68aa486f6ef4cfc9634076dad357e483). I then get a linking error (make minimal_fails):

/usr/bin/ld: /usr/lib/libRmath.a(std_unif.o): in function `set_seed':
(.text+0x0): multiple definition of `set_seed'; Mercury/os/minimal_fails.o:minimal_fails.c:(.text+0xb0): first defined here
/usr/bin/ld: /usr/lib/libRmath.a(std_unif.o): in function `unif_rand':
(.text+0x40): multiple definition of `unif_rand'; Mercury/os/minimal_fails.o:minimal_fails.c:(.text+0xc0): first defined here

If I move those functions to the implementation section, then the linking is okay (make minimal_ok).

Can anyone suggest why this fails and then works?

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>.
_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.