stephenslab / mr.ash.alpha

An R package implementing Mr.ASH method
Other
9 stars 0 forks source link

Compilation Error #5

Closed andrewg3311 closed 2 years ago

andrewg3311 commented 2 years ago

I tried to re-install the package, but it failed to compile:

caisa_rcpp.cpp:93:39: error: ‘PI’ was not declared in this scope 93 | log(2.0 * PI * sigma2) / 2.0 * n - | ^~

So I guess PI isn't defined on line 93 of caisa_rcpp.cpp

pcarbo commented 2 years ago

Hi Andrew I couldn't reproduce your error. You could send me the exact R code you ran, and the output?

andrewg3311 commented 2 years ago

It was just devtools::install_github('stephenslab/mr.ash.alpha')

Compiler line for that file are: g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-devel/include" -DNDEBUG -I'C:/Users/Andrew/Documents/R/win-library/4.1/Rcpp/include' -I'C:/Users/Andrew/Documents/R/win-library/4.1/RcppArmadillo/include' -fopenmp -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c caisa_rcpp.cpp -o caisa_rcpp.o

This also happens with my linux version of R, with g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I'/home/andrew/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/andrew/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include' -fopenmp -fpic -g -O2 -fdebug-prefix-map=/build/r-base-vB4ZXq/r-base-4.1.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c caisa_rcpp.cpp -o caisa_rcpp.o

pcarbo commented 2 years ago

Thanks, and can you send the full output, including the error message?

andrewg3311 commented 2 years ago

Windows:

* installing *source* package 'mr.ash.alpha' ...
** using staged installation
** libs

*** arch - i386
"C:/rtools40/mingw32/bin/"g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-devel/include" -DNDEBUG  -I'C:/Users/Andrew/Documents/R/win-library/4.1/Rcpp/include' -I'C:/Users/Andrew/Documents/R/win-library/4.1/RcppArmadillo/include'     -fopenmp    -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c RcppExports.cpp -o RcppExports.o
"C:/rtools40/mingw32/bin/"g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-devel/include" -DNDEBUG  -I'C:/Users/Andrew/Documents/R/win-library/4.1/Rcpp/include' -I'C:/Users/Andrew/Documents/R/win-library/4.1/RcppArmadillo/include'     -fopenmp    -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c caisa_rcpp.cpp -o caisa_rcpp.o
caisa_rcpp.cpp: In function 'Rcpp::List caisa_rcpp(const mat&, const vec&, const vec&, const vec&, arma::vec&, arma::vec&, arma::vec&, double, const uvec&, int, int, double, double, std::__cxx11::string, bool, bool, bool)':
caisa_rcpp.cpp:93:39: error: 'PI' was not declared in this scope
                             log(2.0 * PI * sigma2) / 2.0 * n -
                                       ^~
make: *** [C:/PROGRA~1/R/R-devel/etc/i386/Makeconf:244: caisa_rcpp.o] Error 1
ERROR: compilation failed for package 'mr.ash.alpha'
* removing 'C:/Users/Andrew/Documents/R/win-library/4.1/mr.ash.alpha'
* restoring previous 'C:/Users/Andrew/Documents/R/win-library/4.1/mr.ash.alpha'

Linux:

Installing package into ‘/home/andrew/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
* installing *source* package ‘mr.ash.alpha’ ...
** using staged installation
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I'/home/andrew/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/andrew/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'   -fopenmp  -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-vB4ZXq/r-base-4.1.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I'/home/andrew/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include' -I'/home/andrew/R/x86_64-pc-linux-gnu-library/4.1/RcppArmadillo/include'   -fopenmp  -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-vB4ZXq/r-base-4.1.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c caisa_rcpp.cpp -o caisa_rcpp.o
caisa_rcpp.cpp: In function ‘Rcpp::List caisa_rcpp(const mat&, const vec&, const vec&, const vec&, arma::vec&, arma::vec&, arma::vec&, double, const uvec&, int, int, double, double, std::string, bool, bool, bool
’:
caisa_rcpp.cpp:93:39: error: ‘PI’ was not declared in this scope
   93 |                             log(2.0 * PI * sigma2) / 2.0 * n -
      |                                       ^~
make: *** [/usr/lib/R/etc/Makeconf:177: caisa_rcpp.o] Error 1
ERROR: compilation failed for package ‘mr.ash.alpha’
* removing ‘/home/andrew/R/x86_64-pc-linux-gnu-library/4.1/mr.ash.alpha’
* restoring previous ‘/home/andrew/R/x86_64-pc-linux-gnu-library/4.1/mr.ash.alpha’
Warning message:
In i.p(...) :
  installation of package ‘/tmp/RtmpXcR98q/file5a541cec88d/mr.ash.alpha_0.1-41.tar.gz’ had non-zero exit status
pcarbo commented 2 years ago

That's a real mystery. I checked on midway2 and also compiled no problem. Can you go into mr_ash.h and change these lines

#ifndef MR_ASH_H
#define MR_ASH_H
#include <RcppArmadillo.h>

to

#ifndef MR_ASH_H
#define MR_ASH_H
#include <math.h>
#include <RcppArmadillo.h>

then run remotes::install_local("mr.ash.alpha")?

andrewg3311 commented 2 years ago

Still fails

But it looks like the constant should be M_PI instead of PI? It works when I make that change (and also #include <math.h>)

pcarbo commented 2 years ago

Can you try again with the latest version? I just commited a change. Indeed it looks like PI is incorrect; see the bottom of this page.

andrewg3311 commented 2 years ago

Works now, thanks!!