Skip to content
Prev 32180 / 63421 Next

Problem building DLL under Windows

Jon,
On Apr 3, 2009, at 10:18 , Jon Senior wrote:

            
That is true only for very specific architectures and OS combinations  
but not on most systems (including Linux). Shared objects must be  
compiled to contain position-independent code (PIC) such that they can  
be re-located when loaded dynamically. In general you cannot use a  
static library in a package unless the library was specifically  
compiled with -fPIC.

Also please note that the above is possibly not what you want: -static  
is not an option that applies to the library - it's a global option  
for the linker which affects *all* libraries and possibly even the crt  
code and compiler-related libraries (this depends on the platform). It  
may cause additional problems since you may need to link R library  
dynamically. All this is not related to Windows - this applies in  
general on any platform (including Linux).
See above, this may not be DLL-specific. Additionally, please make  
sure you're using the right tools (MinGW gcc) for both your static  
library and the package (you have indicated the you do, but just  
making sure :))..
I have tested a toy example with your setup and all was working just  
fine, so for further help you may have to reveal exactly what library  
you are using etc. since the devil may be in the details (if the  
general advice above doesn't help).
AFAICS that is only mentioned with respect to VC - the current tools  
are smart enough with gcc. There are some issues when importing  
variables from R itself, but that should not be related to your code  
(unless you use this feature outside of the standard R headers).

Cheers,
Simon