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

Hagens, M. (Mathilde) M.Hagens at uu.nl
Fri Apr 7 12:20:33 CEST 2017


Dear all,

I’m using compiled code (written in C) in combination with the deSolve package to run a one-dimensional reactive transport model in R. On a server I use running on Linux this works flawlessly, but on a MacBook Pro (macOS 10.12.4) I have problems loading the compiled code into R (version 3.3.3).

The output I get when compiling the code in R using
system("R CMD SHLIB Model.c”)
is:
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c Model.c -o Model.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o Model.so Model.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation

However, when I try to load the resulting shared object via
dyn.load(paste("Model", .Platform$dynlib.ext, sep = ""))
I get:
Error in dyn.load(paste("Model", .Platform$dynlib.ext, sep = "")) :
  unable to load shared object '/Users/mathilde/Model.so':
  dlopen(/Users/mathilde/Model.so, 6): Symbol not found: _dH_dt
  Referenced from: /Users/mathilde/Model.so
  Expected in: flat namespace
 in /Users/mathilde/Model.so

The shared object created after compiling seems to look fine. Also, I tried compiling directly from the Terminal, but that doesn’t make a difference. Strangely, when I ran this model on a Mac in the past (~1 year ago) it also worked without problems, leaving me wondering whether it may be due to an R / macOS update. However, switching to an older R version (2.15.2) didn’t solve the issue either. Has anyone experienced similar behaviour and/or knows of a possible solution?

Best wishes,
Mathilde

	[[alternative HTML version deleted]]



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