[R-sig-dyn-mod] Problem with loading compiled code into R

Hagens, M. (Mathilde) M.Hagens at uu.nl
Sat Apr 8 20:51:31 CEST 2017


Tim, thank you for your clarification. (I did not consider your earlier message harsh.)
I actually had been looking at this, also before posting on the mailing list (maybe I should have mentioned that). My R is compiled using clang, the default for the current CRAN distribution for macOS (see https://cran.r-project.org/doc/manuals/r-release/R-admin.html#macOS). Since the compiler I used was also clang, this does not directly seem to be the problem. However, I am still playing around with some of the compiler flags to see if they may have caused the issue. For this, I find it very helpful to have a look at the Makeconf in R, under file.path(R.home("etc"), "Makeconf”). If anyone has some ideas on what I could change there, that would be highly appreciated as I am still learning about this.
FYI, your example does work with CC instead of CXX.

Thomas, I use deSolve 1.14 and R 3.3.3. My model runs flawlessly on a Linux server (with deSolve 1.14 and R 3.3.1). I don’t have easy access to a Windows computer at the moment. But right now I definitely believe it is a compiler issue.

Once I have a solution (hopefully) I’ll post it here.

Thanks for all your input!
Mathilde

Dr M. (Mathilde) Hagens | Postdoc | Department of Earth Sciences - Geochemistry, Faculty of Geosciences | Utrecht University | Princetonplein 9, 3584 CC Utrecht, the Netherlands | Room 1.13 | P.O. Box 80.021, 3508 TA Utrecht, the Netherlands | tel. +31 30 253 50 37 | M.Hagens at uu.nl<mailto:M.Hagens at uu.nl> | www.uu.nl/staff/MHagens<http://www.uu.nl/staff/MHagens> |

On 8 Apr 2017, at 19:23, Tim Keitt <tkeitt at utexas.edu<mailto:tkeitt at utexas.edu>> wrote:

On Fri, Apr 7, 2017 at 10:08 PM, Tim Keitt <tkeitt at utexas.edu<mailto: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]]

_______________________________________________
R-sig-dynamic-models mailing list
R-sig-dynamic-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models


	[[alternative HTML version deleted]]



More information about the R-sig-dynamic-models mailing list