Skip to content
Prev 27145 / 63461 Next

Problem with dyn.load'ed code

Matt,
On Dec 30, 2007, at 5:25 PM, Matt Calder wrote:

            
The result of redefining a symbol is very much system-dependent. For  
example on Mac OS X it has no adverse effects (i.e your symbols are  
always private unless linked against), because it uses a two-level  
namespace, but on Linux (and most other unices) it does as the  
namespace of an executable is shared among all modules (dynamic and  
static).
Yes, indeed (it's a BLAS level 1 Fortran function, and usually to be  
found in libRblas.so or the external BLAS implementation).
You are confusing the purpose of -static: it only ensures that static  
libraries are used at link time where possible, it doesn't affect your  
code in any way. What you really want is to use
static void dnrm2_(double *out);
in your code instead.

In general, it is a bad idea to use external symbols that clash with  
other libraries (in particular widespread ones such as BLAS),  
especially if your function doesn't perform the same operation. It is  
a good idea to declare all functions that you use internally (i.e.  
that should not be visible to R) as static. However, all this is true  
for C programming in general, not just in conjunction with R.

Cheers,
Simon