[R-sig-dyn-mod] Problem with loading compiled code into R
Tim Keitt
tkeitt at utexas.edu
Sat Apr 8 19:23:20 CEST 2017
On Fri, Apr 7, 2017 at 10:08 PM, Tim Keitt <tkeitt at utexas.edu> wrote:
> If you google that error message, you will find the answer. (clang v. gcc)
>
Let me clarify as I was alerted that that sounded harsh. (Not my intention.)
This error is often reported when linking code C++ compiled with gcc to
code compiled with clang. Those don't work well together. If your R was
compiled with gcc (clang), then you cannot use clang (gcc) to compile code
to link with R (even the g++-alike that comes with llvm).
The trick is to use "R CMD config" to find the compiler used to compile R.
In R (for the C++ compiler):
> Sys.setenv(CXX = system2("R", "CMD config CXX", stdout = TRUE))
> Sys.which(Sys.getenv("CXX")) # should return compiler path
After that, "R CMD SHLIB --clean" should use the correct compiler and link
properly.
You can also try declaring your call point "extern C" to use the C linkage
ABI.
If you're using C rather than C++, then I'm not sure why it does not work
as the C linkage ABI is supposed to be standardized. You can try the above
with CC in place of CXX. Maybe that will fix it.
THK
http://www.keittlab.org/
[[alternative HTML version deleted]]
More information about the R-sig-dynamic-models
mailing list