Skip to content
Prev 79898 / 398502 Next

dyn.load() error: bad external relocation length

Hi Walton.

.C/.Call are interfaces to _compiled_ C routines in a dynamically
loaded library (DLL or DSO - shared object).  A progra
A program is often created from compiling C code into an executable.
We can call the executable via system, but we cannot access its routines 
via .C/.Call.

So, if you have C code, use R CMD SHLIB to compile it into a loadable
libray and use dyn.load() to load it. Putting the code in the src/ 
directory of a package makes the need to do this less explicit.

But if you want to use system(), again it can be done "portably" in a 
package.
Arrange that the package creates and puts the executable in
the package's installed area.  Arrange that the program is
put in, say, inst/bin within the package and then it will be installed 
into the bin/ directory of the package. Then you can access it with

    system.file("bin", "myProg", package = "myPackageName")

and you can use that in your call to system().

The down side is that you will have to ensure that the program is built
in a portable way. So if you won the C code, it is almost the same thing
as building a DLL and using .C/.Call.

HTH

   D.
Walton A. Green wrote: