Message-ID: <CANnL8goZYmP16=iL1oBy8d0N-16LChs709tY2AP4URZ6Dkj-Wg@mail.gmail.com>
Date: 2017-04-08T17:23:20Z
From: Tim Keitt
Subject: [R-sig-dyn-mod] Problem with loading compiled code into R
In-Reply-To: <CANnL8gpFwcp67L4J8Mtm-0Xrm8nrw=hua_eEDOLyZDbdeBgGSw@mail.gmail.com>
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]]