Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation failed error #4

Open
isaac2lord opened this issue Jun 13, 2021 · 6 comments
Open

Compilation failed error #4

isaac2lord opened this issue Jun 13, 2021 · 6 comments

Comments

@isaac2lord
Copy link

Hello

I get "make: *** [PF/dists.o] Error 1" error while trying to install the library

System info


$ uname -a
Linux apsrp07947 3.10.0-1160.2.1.el7.x86_64 #1 SMP Mon Sep 21 21:00:09 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux


$ g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.




> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server 7.9 (Maipo)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.6.0 tools_3.6.0    remotes_2.4.0 

Steps:

1- I installed Rcpp and RcppArmadillo

2- Try to install the library by both install.packages("dynamichazard") and remotes::install_github("boennecd/dynamichazard").

Error log (I used MYDIR to mask the full address):


> install.packages("dynamichazard")
Installing package into ‘<MYDIR>/app/R_Library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/dynamichazard_0.6.8.tar.gz'
Content type 'application/x-gzip' length 4447834 bytes (4.2 MB)
==================================================
downloaded 4.2 MB

* installing *source* package ‘dynamichazard’ ...
** package ‘dynamichazard’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -DUSE_FC_LEN_T -I"<MYDIR>/app/R_Library/Rcpp/include" -I"<MYDIR>/app/R_Library/RcppArmadillo/include" -I/usr/local/include -fopenmp -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c PF/PF_score_n_Hess.cpp -o PF/PF_score_n_Hess.o
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -DUSE_FC_LEN_T -I"<MYDIR>/app/R_Library/Rcpp/include" -I"<MYDIR>/app/R_Library/RcppArmadillo/include" -I/usr/local/include -fopenmp -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c PF/PFs.cpp -o PF/PFs.o
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -DUSE_FC_LEN_T -I"<MYDIR>/app/R_Library/Rcpp/include" -I"<MYDIR>/app/R_Library/RcppArmadillo/include" -I/usr/local/include -fopenmp -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c PF/covarmat.cpp -o PF/covarmat.o
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -DUSE_FC_LEN_T -I"<MYDIR>/app/R_Library/Rcpp/include" -I"<MYDIR>/app/R_Library/RcppArmadillo/include" -I/usr/local/include -fopenmp -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c PF/resamplers.cpp -o PF/resamplers.o
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -DUSE_FC_LEN_T -I"<MYDIR>/app/R_Library/Rcpp/include" -I"<MYDIR>/app/R_Library/RcppArmadillo/include" -I/usr/local/include -fopenmp -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c PF/densities.cpp -o PF/densities.o
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -DUSE_FC_LEN_T -I"<MYDIR>/app/R_Library/Rcpp/include" -I"<MYDIR>/app/R_Library/RcppArmadillo/include" -I/usr/local/include -fopenmp -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c PF/cond_approx.cpp -o PF/cond_approx.o
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -DUSE_FC_LEN_T -I"<MYDIR>/app/R_Library/Rcpp/include" -I"<MYDIR>/app/R_Library/RcppArmadillo/include" -I/usr/local/include -fopenmp -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c PF/dists.cpp -o PF/dists.o
PF/dists.cpp:219:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]
 #pragma omp declare reduction(armaVP: arma::vec: omp_out += omp_in)
 ^
PF/dists.cpp:220:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]
 #pragma omp declare reduction(armaMP: arma::mat: omp_out += omp_in)
 ^
PF/dists.cpp: In member function ‘arma::vec observational_cdist<T>::gradient(const vec&) const’:
PF/dists.cpp:292:13: error: expected ‘+’, ‘*’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘armaVP’
   reduction(armaVP:result) firstprivate(first_it)
             ^
PF/dists.cpp: In member function ‘arma::mat observational_cdist<T>::neg_Hessian(const vec&) const’:
PF/dists.cpp:330:53: error: expected ‘+’, ‘*’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘armaMP’
 #pragma omp parallel for schedule(static) reduction(armaMP:result) \
                                                     ^
make: *** [PF/dists.o] Error 1
ERROR: compilation failed for package ‘dynamichazard’
* removing ‘<MYDIR>/app/R_Library/dynamichazard’
Warning in install.packages :
  installation of package ‘dynamichazard’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/Rtmps7OTdz/downloaded_packages’

Appreciate any words of wisdom that might help to tackle this.

Does the package have any binary version to avoid compilation?

@boennecd
Copy link
Owner

boennecd commented Jun 14, 2021

The build error seems to be related to the user defined reduction using OpenMP. I think this was first added in OpenMP 4.0 so perhaps you do not have a recent enough version of OpenMP?

If this is true, then you can try to download the source and remove $(SHLIB_OPENMP_CXXFLAGS) from these lines:

PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CXXFLAGS)

which should remove the -fopenmp flag. The downside is that you cannot do computation in parallel. Alternatively, do you have a more recent compiler you can use?

@isaac2lord
Copy link
Author

Thanks for the reply.

unfortunately my hands are limited in installing a lot of stuff in the box I am given. I might have a chance to upgrade gcc. Which version of gcc is compatible with c++11 and this library? https://gcc.gnu.org/releases.html

Alternatively I'd still think having a binary compiled version available is a good to have?

@boennecd
Copy link
Owner

I might have a chance to upgrade gcc. Which version of gcc is compatible with c++11 and this library? https://gcc.gnu.org/releases.html

I know that the package used to build with Rtools35.exe which seems to have been based on GCC 4.9.3 and Mingw-w64 v3. From https://gcc.gnu.org/wiki/openmp, it seems like GCC 4.9 supports OpenMP 4.0 which would explain the issues you are seeing with GCC 4.8.5 and why it used to work with the old Rtools.

Alternatively I'd still think having a binary compiled version available is a good to have?

To be honest, I have never tried to build and distribute the binary myself. I am not sure if I will have the time to do this anytime soon.

@boennecd
Copy link
Owner

Oh and I forgot to mention that I do not think it is C++11 which is the issue but rather OpenMP.

@isaac2lord
Copy link
Author

Say I 'd be able to install the second version of GCC. Is there an easy way to point to a specific binary when installing dynamichazard?

@boennecd
Copy link
Owner

You can use the CC, CXX, CXX11, and FC flags in your ~/.R/Makevars file. E.g., I have

CC=gcc-10
CXX=g++-10 
CXX11=g++-10
FC=gfortran-10

See https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Customizing-package-compilation for details. You can check that you have set this up correctly by running e.g. R CMD config CXX11 which gives me g++-10.

You can also have the Makevars file at some other location using the R_MAKEVARS_USER environment variable. For instance,

echo "CXX=some/path/g++" >> /tmp/Makevars
export R_MAKEVARS_USER=/tmp/Makevars
R CMD config CXX
#> some/path/g++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants