Closed Cyprian95 closed 5 years ago
Hi @Cyprian95 ,
The latest github version of nlmixr requires C++14
. I haven't tried it on a mac yet. Let me try and update the instructions if I need to.
Hi @Cyprian95,
I think you simply need to add the C++14
configuration file:
# ~/.R/Makevars
CXX14FLAGS=-O2 -march=native -mtune=native -arch x86_64 -ftemplate-depth-256 -fPIC
For me, the instructions seemed to work just fine. I ran the theo_sd example with focei
and saem
and both seemed OK.
Hi @mattfidler, first of all, thank you very much for coming back to me. I have followed your suggestions and the updated instructions for mac. Unfortunately, the same issue still persists:
ode_cmt1.cpp:7:10: fatal error: 'stan/math/rev/core.hpp' file not found
include <stan/math/rev/core.hpp>
I have also additionally tried reinstalling R&R Studio with the removal of Library (containing all the packages), so had a fresh clean attempt at reinstallation. I removed R from applications and used the terminal commands:
rm -rf /Applications/R.app sudo rm -rf /Library/Frameworks/R.framework sudo rm /usr/bin/{R,Rscript}
My Makevars file was edited using:
file.edit(file.path("~/.R", "Makevars"))
and I have added the line as instructed. Below
sessionInfo() R version 3.6.1 (2019-07-05) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Mojave 10.14.6
Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding
locale: [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages: [1] stats graphics grDevices datasets utils methods base
other attached packages: [1] devtools_2.1.0 usethis_1.5.1 RxODE_0.9.1-3 reticulate_1.13
loaded via a namespace (and not attached): [1] Rcpp_1.0.2 pillar_1.4.2 compiler_3.6.1 prettyunits_1.0.2 PreciseSums_0.3 remotes_2.1.0 tools_3.6.1
[8] testthat_2.2.1 pkgload_1.0.2 pkgbuild_1.0.4 mvnfast_0.2.5 digest_0.6.20 jsonlite_1.6 memoise_1.1.0
[15] tibble_2.1.3 gtable_0.3.0 lattice_0.20-38 pkgconfig_2.0.2 rlang_0.4.0 Matrix_1.2-17 cli_1.1.0
[22] rstudioapi_0.10 curl_4.0 withr_2.1.2 desc_1.2.0 fs_1.3.1 rprojroot_1.3-2 grid_3.6.1
[29] tidyselect_0.2.5 glue_1.3.1 R6_2.4.0 processx_3.4.1 sessioninfo_1.1.1 polyclip_1.10-0 callr_3.3.1
[36] ggplot2_3.2.1 purrr_0.3.2 tweenr_1.0.1 farver_1.1.0 magrittr_1.5 backports_1.1.4 ps_1.3.0
[43] scales_1.0.0 MASS_7.3-51.4 units_0.6-3 assertthat_0.2.1 ggforce_0.3.0 colorspace_1.4-1 lotri_0.1.1
[50] lazyeval_0.2.2 munsell_0.5.0 crayon_1.3.4Sys.getenv("PATH") [1] "/usr/local/clang8/bin:/usr/local/gfortran/bin:/usr/local/clang6/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/MacGPG2/bin:/opt/X11/bin" .libPaths() [1] "/Library/Frameworks/R.framework/Versions/3.6/Resources/library"
Apart from sessionInfo(); Sys.getenv("PATH"); and .libPaths(), would anything else be helpful to solve this mystery?
What happens when you install the stan headers?
install.packages("StanHeaders")
install.packages("StanHeaders") Error in install.packages : Updating loaded packages
Restarting R session...
install.packages("StanHeaders") trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/StanHeaders_2.18.1-10.tgz' Content type 'application/x-gzip' length 1492271 bytes (1.4 MB)
downloaded 1.4 MB
The downloaded binary packages are in /var/folders/c6/sxn57gws03d4_0r_5jr_kz9c0000gn/T//RtmpQYCX5Y/downloaded_packages
library("StanHeaders")
would you mind providing a full script for the Makevars file for the ~/.R location? Or could you confirm whether it is supposed to work only as being composed of a single line of code - aka the one that you've provided? I've encountered similar issues with RStan compilation on the web, being resolved, for instance, by substitution of -Wall with -W in the Makevars or Makeconfig scripts: https://discourse.mc-stan.org/t/suppressing-compiler-warnings-in-rstan/4910
This would not be applicable to Makevars with only the line you provided. As I have no previous experience with C++, I am not sure how to approach this compilation issue. Would you advise on modifying Makeconf file, similarily to your advice regarding Makevars, as well?
Below I'm providing the current state of Makeconfig file:
> # etc/Makeconf. Generated from Makeconf.in by configure.
> #
> # ${R_HOME}/etc/Makeconf
> #
> # R was configured using the following call
> # (not including env. vars and site configuration)
> # configure 'CC=clang' 'CXX=clang++' 'OBJC=clang' 'CFLAGS=-Wall -g -O2' 'CPPFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include' 'CXXFLAGS=-Wall -g -O2' 'OBJCFLAGS=-Wall -g -O2' 'FCFLAGS=-Wall -g -O2' 'F77FLAGS=-Wall -g -O2' '--enable-memory-profiling' '--x-libraries=/opt/X11/lib' '--enable-R-framework' 'PKG_CONFIG_PATH=/usr/lib/pkgconfig:/opt/X11/lib/pkgconfig:/usr/local/lib/pkgconfig'
>
> ## This fails if it contains spaces, or if it is quoted
> include $(R_SHARE_DIR)/make/vars.mk
>
> AR = ar
> BLAS_LIBS = -L"$(R_HOME)/lib$(R_ARCH)" -lRblas
> C_VISIBILITY =
> CC = clang
> CFLAGS = -Wall -g -O2 $(LTO)
> CPICFLAGS = -fPIC
> CPPFLAGS = -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include
> CXX = clang++ -std=gnu++11
> CXXCPP = $(CXX) -E
> CXXFLAGS = -Wall -g -O2 $(LTO)
> CXXPICFLAGS = -fPIC
> CXX98 = clang++
> CXX98FLAGS = -Wall -g -O2 $(LTO)
> CXX98PICFLAGS = -fPIC
> CXX98STD = -std=gnu++98
> CXX11 = clang++
> CXX11FLAGS = -Wall -g -O2 $(LTO)
> CXX11PICFLAGS = -fPIC
> CXX11STD = -std=gnu++11
> CXX14 = clang++
> CXX14FLAGS = -Wall -g -O2 $(LTO)
> CXX14PICFLAGS = -fPIC
> CXX14STD = -std=gnu++14
> CXX17 = clang++
> CXX17FLAGS = -Wall -g -O2 $(LTO)
> CXX17PICFLAGS = -fPIC
> CXX17STD = -std=gnu++17
> CXX_VISIBILITY =
> DYLIB_EXT = .dylib
> DYLIB_LD = $(CC)
> DYLIB_LDFLAGS = -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -fopenmp# $(CFLAGS) $(CPICFLAGS)
> DYLIB_LINK = $(DYLIB_LD) $(DYLIB_LDFLAGS) $(LDFLAGS)
> ECHO = echo
> ECHO_C = \c
> ECHO_N =
> ECHO_T =
> F_VISIBILITY =
> ## FC is the compiler used for all Fortran as from R 3.6.0
> FC = gfortran
> FCFLAGS = -Wall -g -O2 $(LTO)
> ## additional libs needed when linking with $(FC), e.g. on some Oracle compilers
> FCLIBS_XTRA =
> FFLAGS = -Wall -g -O2 $(LTO)
> FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
> FPICFLAGS = -fPIC
> FOUNDATION_CPPFLAGS =
> FOUNDATION_LIBS = -framework Foundation
> JAR = /usr/bin/jar
> JAVA = /usr/bin/java
> JAVAC = /usr/bin/javac
> JAVAH = /usr/bin/javah
> ## JAVA_HOME might be used in the next three.
> ## They are for packages 'JavaGD' and 'rJava'
> JAVA_HOME = /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
> JAVA_CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
> JAVA_LIBS = -L$(JAVA_HOME)/lib/server -ljvm
> JAVA_LD_LIBRARY_PATH = $(JAVA_HOME)/lib/server
> LAPACK_LIBS = -L"$(R_HOME)/lib$(R_ARCH)" -lRlapack
> LDFLAGS = -L/usr/local/lib
> ## we only need this is if it is external, as otherwise link to R
> LIBINTL= -Wl,-framework -Wl,CoreFoundation
> LIBM =
> LIBR0 = -L"$(R_HOME)/lib$(R_ARCH)"
> LIBR1 = -lR
> LIBR = -F/Library/Frameworks/R.framework/.. -framework R
> LIBS = -lpcre -llzma -lbz2 -lz -licucore -ldl -lm -liconv
> ## needed by R CMD config
> LIBnn = lib
> LIBTOOL = $(SHELL) "$(R_HOME)/bin/libtool"
> LTO =
> ## needed to build applications linking to static libR
> MAIN_LD = $(CC)
> MAIN_LDFLAGS = -fopenmp
> MAIN_LINK = $(MAIN_LD) $(MAIN_LDFLAGS) $(LDFLAGS)
> MKINSTALLDIRS = "$(R_HOME)/bin/mkinstalldirs"
> OBJC = clang
> OBJCFLAGS = -Wall -g -O2 -fobjc-exceptions $(LTO)
> OBJC_LIBS = -lobjc
> OBJCXX = clang++
> R_ARCH =
> RANLIB = ranlib
> SAFE_FFLAGS = -Wall -g -O2 -msse2 -mfpmath=sse
> SED = /usr/bin/sed
> SHELL = /bin/sh
> SHLIB_CFLAGS =
> SHLIB_CXXFLAGS =
> SHLIB_CXXLD = $(CXX)
> SHLIB_CXXLDFLAGS = -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress
> SHLIB_CXX98LD = $(CXX98) $(CXX98STD)
> SHLIB_CXX98LDFLAGS = -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress
> SHLIB_CXX11LD = $(CXX11) $(CXX11STD)
> SHLIB_CXX11LDFLAGS = -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress
> SHLIB_CXX14LD = $(CXX14) $(CXX14STD)
> SHLIB_CXX14LDFLAGS = -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress
> SHLIB_CXX17LD = $(CXX17) $(CXX17STD)
> SHLIB_CXX17LDFLAGS = -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress
> SHLIB_EXT = .so
> SHLIB_FFLAGS =
> SHLIB_LD = $(CC)
> SHLIB_LDFLAGS = -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress# $(CFLAGS) $(CPICFLAGS)
> SHLIB_LIBADD =
> ## We want to ensure libR is picked up from $(R_HOME)/lib
> ## before e.g. /usr/local/lib if a version is already installed.
> SHLIB_LINK = $(SHLIB_LD) $(SHLIB_LDFLAGS) $(LIBR0) $(LDFLAGS)
> SHLIB_OPENMP_CFLAGS = -fopenmp
> SHLIB_OPENMP_CXXFLAGS = -fopenmp
> SHLIB_OPENMP_FFLAGS = -fopenmp
> STRIP_STATIC_LIB = strip -S
> STRIP_SHARED_LIB = strip -x
> TCLTK_CPPFLAGS = -I/usr/local/include -I/usr/local/include -I/opt/X11/include
> TCLTK_LIBS = -L/usr/local/lib -ltcl8.6 -L/usr/local/lib -ltk8.6 -L/opt/X11/lib -lX11 -Wl,-weak-lXss -lXext
> YACC = bison -y
>
> ## Legacy settings: no longer used by R as of 3.6.0
> ## Setting FC often sets F77 (on Solaris make even if set)
> ## so must follow FC in this file.
> F77 = gfortran
> FCPICFLAGS = -fPIC
> F77_VISIBILITY =
> SHLIB_FCLD = $(FC)
> SHLIB_FCLDFLAGS = -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress
> SHLIB_OPENMP_FCFLAGS = -fopenmp
>
>
> ## for linking to libR.a
> STATIC_LIBR = # "$(R_HOME)/lib$(R_ARCH)/libR.a" $(BLAS_LIBS) $(FLIBS) $(LIBINTL) -lreadline $(LIBS)
>
> ## These are recorded as macros for legacy use in packages
> ## set on AIX, formerly for old glibc (-D__NO_MATH_INLINES)
> R_XTRA_CFLAGS =
> ## was formerly set on HP-UX
> R_XTRA_CPPFLAGS = -I"$(R_INCLUDE_DIR)" -DNDEBUG
> ## currently unset
> R_XTRA_CXXFLAGS =
> ## used for gfortran in R > 3.6.0
> R_XTRA_FFLAGS =
>
> ## SHLIB_CFLAGS SHLIB_CXXFLAGS SHLIB_FFLAGS are apparently currently unused
> ## SHLIB_CXXFLAGS is undocumented, there is no SHLIB_FCFLAGS
> ALL_CFLAGS = $(PKG_CFLAGS) $(CPICFLAGS) $(SHLIB_CFLAGS) $(CFLAGS)
> ALL_CPPFLAGS = -I"$(R_INCLUDE_DIR)" -DNDEBUG $(PKG_CPPFLAGS) $(CLINK_CPPFLAGS) $(CPPFLAGS)
> ALL_CXXFLAGS = $(PKG_CXXFLAGS) $(CXXPICFLAGS) $(SHLIB_CXXFLAGS) $(CXXFLAGS)
> ALL_OBJCFLAGS = $(PKG_OBJCFLAGS) $(CPICFLAGS) $(SHLIB_CFLAGS) $(OBJCFLAGS)
> ALL_OBJCXXFLAGS = $(PKG_OBJCXXFLAGS) $(CXXPICFLAGS) $(SHLIB_CXXFLAGS) $(OBJCXXFLAGS)
> ALL_FFLAGS = $(PKG_FFLAGS) $(FPICFLAGS) $(SHLIB_FFLAGS) $(FFLAGS)
> ## can be overridden by R CMD SHLIB
> P_FCFLAGS = $(PKG_FFLAGS)
> ALL_FCFLAGS = $(P_FCFLAGS) $(FPICFLAGS) $(SHLIB_FFLAGS) $(FCFLAGS)
> ## LIBR here as a couple of packages use this without SHLIB_LINK
> ALL_LIBS = $(PKG_LIBS) $(SHLIB_LIBADD) $(LIBR) $(LIBINTL)
>
> .SUFFIXES:
> .SUFFIXES: .c .cc .cpp .d .f .f90 .f95 .m .mm .M .o
>
> .c.o:
> $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
> .c.d:
> @echo "making $@ from $<"
> @$(CC) -MM $(ALL_CPPFLAGS) $< > $@
> .cc.o:
> $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $@
> .cpp.o:
> $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $@
> .cc.d:
> @echo "making $@ from $<"
> @$(CXX) -M $(ALL_CPPFLAGS) $< > $@
> .cpp.d:
> @echo "making $@ from $<"
> @$(CXX) -M $(ALL_CPPFLAGS) $< > $@
> .m.o:
> $(OBJC) $(ALL_CPPFLAGS) $(ALL_OBJCFLAGS) -c $< -o $@
> .m.d:
> @echo "making $@ from $<"
> @clang -MM $(ALL_CPPFLAGS) $< > $@
> .mm.o:
> $(OBJCXX) $(ALL_CPPFLAGS) $(ALL_OBJCXXFLAGS) -c $< -o $@
> .M.o:
> $(OBJCXX) $(ALL_CPPFLAGS) $(ALL_OBJCXXFLAGS) -c $< -o $@
> .f.o:
> $(FC) $(ALL_FFLAGS) -c $< -o $@
> ## @FCFLAGS_f9x@ are flags needed to recognise the extensions
> .f95.o:
> $(FC) $(ALL_FCFLAGS) -c $< -o $@
> .f90.o:
> $(FC) $(ALL_FCFLAGS) -c $< -o $@
>
Hi @Cyprian95,
I used a the single line of code in Makevars
to install.
The error you show seems to be on the installation of StanHeaders
, so perhaps you can retry installing nlmixr
after you installed the recent StanHeaders
. There is likely a (undeclared) version requirement in nlmixr
Here is the offending compile line:
ode_cmt1.cpp:7:10: fatal error: 'stan/math/rev/core.hpp' file not found
#include <stan/math/rev/core.hpp>
Also how do you install R? I install R from CRAN. Perhaps you use homebrew
? I haven't tested that approach.
@mattfidler, I have used the Cran version, but in-between reinstallations, I have not removed XCode. I will try to go through everything once more and if that fails as well, will do a hard reboot of my mac. Thank you very much for your help! I will update how it turned out in the end :)
@mattfidler FWIW, I would like to share a similar experience. I ended up not using Mac or Linux as I could not get it to work even after a day of trying to get this to install. reticulate's python 3 detection was a hit or miss and I had to end up using use_python()
after every restart. I will have to give it a spin again sometime based on information here.
The windows experience was surprisingly smoother and it works out of the box.
Thanks @vjd
We are eventually dropping python (There is an experimental branch that works without python), so that should be easier. I have been told that the Mac cran binaries will include all the necesary components so install should be simply (at that future point) installing the R package and the R toolchain for compiling binaries.
The easiest way on a mac is to probably use the Docker image, actually. So if you want to try that approach let me know.
@Cyprian95,
Did you get this working?
Hey, Trying to download nlmixr on Mac 10.14.6, once I get to the RxODE download step the following error occurs:
`Downloading GitHub repo nlmixrdevelopment/RxODE@master Your system is ready to build packages! ✔ checking for file ‘/private/var/folders/44/pnlmng852qq4dzdk6s2gfwsc0000gn/T/RtmpZ4Lhv2/remotes3a3441d1b8f/nlmixrdevelopment-RxODE-c54dcb3/DESCRIPTION’ (399ms) ─ preparing ‘RxODE’: (612ms) ✔ checking DESCRIPTION meta-information ... ─ cleaning src ─ running ‘cleanup’ ─ checking for LF line-endings in source and make files and shell scripts (390ms) ─ checking for empty or unneeded directories Removed empty directory ‘RxODE/man-roxygen’ ─ building ‘RxODE_0.9.1-4.tar.gz’
/private/var/folders/44/pnlmng852qq4dzdk6s2gfwsc0000gn/T/RtmpCfxlqs/R.INSTALL6de490070bf/RxODE': configure: error: cannot run C compiled programs. If you meant to cross compile, use
--host'.
See `config.log' for more details
ERROR: configuration failed for package ‘RxODE’If you could please help, I'd really appreciate it!
Thank you
The easiest way to install nlmixr on Mac right now is to install from CRAN that is:
install.packages("nlmixr")
Otherwise the install instructions should follow the readme on this website.
If that doesn't work, I would take the docker approach.
@mattfidler Thank you so much ! I think it worked. How do I test to check that it has downloaded properly? thank you again
You have to make sure you can compile C programs and run sympy.
An easy way to test that is:
library(RxODE)
mod1 <-RxODE({
C2 = centr/V2;
C3 = peri/V3;
d/dt(depot) =-KA*depot;
d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3;
d/dt(peri) = Q*C2 - Q*C3;
d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff;
});
If this is successful you can test if you have sympy installed correctly:
> rxSymPyVersion()
Using sympy via reticulate
[1] 1
I'm supposing this is fixed. If not feel free to open a new issue.
Hello
I have tried reinstalling nlmixr on my device, since initially the installed version was failing to generate vpc plots. I have recently tried reinstalling with a more updated version of R (version 3.6.0), and managed to get in the installation to the stage of running “library(RxODE); rxTest();” without any major issues:
results test rx
Results ══════════════════════════════════════════════════════ Duration: 3980.9 s OK: 5202 Failed: 1 Warnings: 3 Skipped: 3
However, proceeding to install nlmixr, it couldn’t move forward because of a warning message “nlmixr not available for R version 3.6.0. Thus, I reinstalled everything step by step as instructed on your github page (with R 3.5.2), but now there seems to be some compilation issues, whenever trying to install the nlmixr package. For some of my attempts, I was ending up with this error:
Also, I am not quite sure how to allow for python3 to be used by nlmixr. During the time it worked (without vpc), it used python 2.7. I did modify the R.profile file in order for it to recognize the newer version but to no avail.
I have also tried installing Rcpp (and all related files e.g. RccpEigen) separately within R via install.packages() command. Additionally, I’ve installed Eigen through brew (all of these steps were following a series of tries on a normal process of installation, all rendering exactly the same result). I even reinstalled brew and will attempt reinstalling XCode if nothing else helps.
If I could facilitate by providing some additional info, I'll gladly do it.
If anyone has been using nlmixr with R 3.6.0 on Mac without any issues and could instruct me on how to remove any files that could have altered compilation, I would be extremely grateful!
Additional info on the session, SnakeCharmR etc:
Suggestion:
Lastly: A bit about my session:
Kindly thanking in advance for all help provided!