vdorie / treatSens

15 stars 5 forks source link

Unable to install due to c++ compile errors #10

Open chaolyang opened 5 years ago

chaolyang commented 5 years ago

I'm trying to install the package via install_github("vdorie/treatSens") but am seeing errors using the default clang-4.0 on MacOS Mojave (the full log is posted at the bottom). When I switch to gcc-8.0 which was installed via homebrew, the error becomes

g++-8 -std=gnu++11 -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 treatSens.so R_interface.o bartTreatmentModel.o guessNumCores.o probitEMTreatmentModel.o probitTreatmentModel.o sensitivityAnalysis.o glm/libglm.a external/libexternal.a stan_files/cont_binary_mlm.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/Cellar/gcc/8.2.0/lib/gcc/8 -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.5/Resources/library/treatSens/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘treatSens’ in .doLoadActions(where, attach):
 error in load action .__A__.1 for package treatSens: is(module, "character"): object 'm' not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/treatSens’

Since it didn't work, I tried to revert it and reinstall using install_github("vdorie/treatSens"), but saw the error attached at the bottom.

What is it I'm doing wrong? I was able to install the package with a vanilla installation of R and RStudio at first a couple of weeks ago with no error. Then I tried to clone this repo and build it locally. It had some compiler errors which was not encountered with I installed using install_github("vdorie/treatSens"). The only thing I did was that I changed my .R/Makevar to set the gcc compiler to gcc-8.0 which I installed via brew, then I reverted it. Not sure why it worked at the beginning and what's changed. A reinstallation of R didn't help either.

The full error log for install_github("vdorie/treatSens"):

error.txt

vdorie commented 5 years ago

It's all the Stan stuff. I'm going to factor it into it's own branch but it'll take me a bit of time. Possibly later today or tomorrow.

chaolyang commented 5 years ago

@vdorie Thank you! However, I still don't understand why it worked before. The last commit was 4 months ago and my first successful installation was about a month ago, so I feel I'm missing something on my end.

Please let me know if you have a working solution. Really appreciate your help!

vdorie commented 5 years ago

It would probably due to some package upstream being updated. If they're not up-to-date, I would try installing rstan, StanHeaders, BH, Rcpp, and RcppEigen. rstan also moved to C++14 and that might be causing the problem since I have to update the package to reflect that. Doing so breaks the default install on Windows, which is I want to strip it out.

I really doubt this will help, but you can try modifying your Makevars to include:

CXX14FLAGS=-O3 -march=native -mtune=native -arch x86_64 -ftemplate-depth-256

Also, when you switch compilers make sure that CXX14 is set correctly by checking R CMD config CXX14.

chaolyang commented 5 years ago

I tried

install.packages(c("rstan", "StanHeaders", "BH", "Rcpp", "RcppEigen"))

and including the suggested line in my Makevars and it didn't solve the problem. For now I installed an earlier branch of treatSens in order to unblock my code. Any update here is much appreciated!

vdorie commented 5 years ago

I've removed stan from master, so hopefully it'll install now. Thanks for letting me know about the issue.