Mouse-Imaging-Centre / RMINC

Statistics for MINC volumes: A library to integrate voxel-based statistics for MINC volumes into the R environment. Supports getting and writing of MINC volumes, running voxel-wise linear models, correlations, etc.; correcting for multiple comparisons using the False Discovery Rate, and more. With contributions from Jason Lerch, Chris Hammill, Jim Nikelski and Matthijs van Eede. Some additional information can be found here:
https://mouse-imaging-centre.github.io/RMINC
Other
22 stars 17 forks source link

Can't install RMINC on Ubuntu #314

Closed guilhermepovala closed 4 months ago

guilhermepovala commented 1 year ago

Hello,

I'm facing a problem when trying to install RMINC on ubuntu (20.04 or 22.04). This is the error I'm getting when trying to install. Note that I have set the MINC_PATH and also install HDF5. Is there anything that I might be missing during this process?

> devtools::install_github("Mouse-Imaging-Centre/RMINC")
Downloading GitHub repo Mouse-Imaging-Centre/RMINC@HEAD
── R CMD build ─────────────────────────────────────────────────────────────────────────✔  checking for file ‘/tmp/RtmpHh9zPL/remotes18e9dfd30a6/Mouse-Imaging-Centre-RMINC-edfa0f4/DESCRIPTION’ (337ms)─  preparing ‘RMINC’:✔  checking DESCRIPTION meta-information ...
─  cleaning src─  running ‘cleanup’─  checking for LF line-endings in source and make files and shell scripts─  checking for empty or unneeded directories
   Removed empty directory ‘RMINC/etc’
─  looking to see if a ‘data/datalist’ file should be added─  building ‘RMINC_1.5.3.0.tar.gz’
   Warning: invalid uid value replaced by that for user 'nobody'
   Warning: invalid gid value replaced by that for user 'nobody'

Installing package into ‘/home/povalag/R/x86_64-pc-linux-gnu-library/4.3’
(as ‘lib’ is unspecified)
* installing *source* package ‘RMINC’ ...
** using staged installation
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -std=gnu++17 accepts -g... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... no
checking for mawk... mawk
configure: Searching for libminc
configure: MINC_PATH was specified
configure: MINC_PATH set to /opt/minc/1.9.18
configure: override by setting the environment variable MINC_PATH
configure: or by setting --with-build-path as a configure argument
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for h5cc... /usr/bin/h5cc
checking for HDF5 libraries... yes (version 1.10.7)
checking hdf5.h usability... yes
checking hdf5.h presence... yes
checking for hdf5.h... yes
checking for H5Fcreate in -lhdf5... yes
checking for main in -lhdf5_hl... yes
checking for matching HDF5 Fortran wrapper... /usr/bin/h5fc
checking for mifree_name in -lminc2... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for size_t... yes
checking for error_at_line... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C compiler: ‘gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0’
using C++ compiler: ‘g++ (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0’
using C++11
gcc -I"/usr/share/R/include" -DNDEBUG -I/opt/minc/1.9.18/include -I/usr/include/hdf5/serial -I/usr/include -I'/usr/lib/R/site-library/Rcpp/include'     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-dIDxrQ/r-base-4.3.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c RMINC_init.c -o RMINC_init.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/opt/minc/1.9.18/include -I/usr/include/hdf5/serial -I/usr/include -I'/usr/lib/R/site-library/Rcpp/include'     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-dIDxrQ/r-base-4.3.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/opt/minc/1.9.18/include -I/usr/include/hdf5/serial -I/usr/include -I'/usr/lib/R/site-library/Rcpp/include'     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-dIDxrQ/r-base-4.3.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c anat_summaries.cpp -o anat_summaries.o
gcc -I"/usr/share/R/include" -DNDEBUG -I/opt/minc/1.9.18/include -I/usr/include/hdf5/serial -I/usr/include -I'/usr/lib/R/site-library/Rcpp/include'     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-dIDxrQ/r-base-4.3.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c minc2_read.c -o minc2_read.o
gcc -I"/usr/share/R/include" -DNDEBUG -I/opt/minc/1.9.18/include -I/usr/include/hdf5/serial -I/usr/include -I'/usr/lib/R/site-library/Rcpp/include'     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-dIDxrQ/r-base-4.3.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c minc2_support.c -o minc2_support.o
gcc -I"/usr/share/R/include" -DNDEBUG -I/opt/minc/1.9.18/include -I/usr/include/hdf5/serial -I/usr/include -I'/usr/lib/R/site-library/Rcpp/include'     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-dIDxrQ/r-base-4.3.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c minc2_write.c -o minc2_write.o
gcc -I"/usr/share/R/include" -DNDEBUG -I/opt/minc/1.9.18/include -I/usr/include/hdf5/serial -I/usr/include -I'/usr/lib/R/site-library/Rcpp/include'     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-dIDxrQ/r-base-4.3.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c minc_anova.c -o minc_anova.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/opt/minc/1.9.18/include -I/usr/include/hdf5/serial -I/usr/include -I'/usr/lib/R/site-library/Rcpp/include'     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-dIDxrQ/r-base-4.3.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c minc_apply.cpp -o minc_apply.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/opt/minc/1.9.18/include -I/usr/include/hdf5/serial -I/usr/include -I'/usr/lib/R/site-library/Rcpp/include'     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-dIDxrQ/r-base-4.3.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c minc_cpp.cpp -o minc_cpp.o
gcc -I"/usr/share/R/include" -DNDEBUG -I/opt/minc/1.9.18/include -I/usr/include/hdf5/serial -I/usr/include -I'/usr/lib/R/site-library/Rcpp/include'     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-dIDxrQ/r-base-4.3.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c minc_reader.c -o minc_reader.o
gcc -I"/usr/share/R/include" -DNDEBUG -I/opt/minc/1.9.18/include -I/usr/include/hdf5/serial -I/usr/include -I'/usr/lib/R/site-library/Rcpp/include'     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-dIDxrQ/r-base-4.3.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c modelling_functions.c -o modelling_functions.o
In file included from /usr/share/R/include/R.h:78,
                 from minc_reader.h:12,
                 from modelling_functions.c:1:
modelling_functions.c: In function ‘voxel_lm’:
modelling_functions.c:541:12: error: too few arguments to function ‘dpotri_’
  541 |   F77_CALL(dpotri)("Upper", &p, x, &n, &info);
      |            ^~~~~~
/usr/share/R/include/R_ext/RS.h:77:25: note: in definition of macro ‘F77_CALL’
   77 | # define F77_CALL(x)    x ## _
      |                         ^
/usr/share/R/include/R_ext/Lapack.h:831:10: note: declared here
  831 | F77_NAME(dpotri)(const char* uplo, const int* n,
      |          ^~~~~~
/usr/share/R/include/R_ext/RS.h:77:25: note: in definition of macro ‘F77_CALL’
   77 | # define F77_CALL(x)    x ## _
      |                         ^
/usr/share/R/include/R_ext/Lapack.h:831:1: note: in expansion of macro ‘F77_NAME’
  831 | F77_NAME(dpotri)(const char* uplo, const int* n,
      | ^~~~~~~~
make: *** [/usr/lib/R/etc/Makeconf:191: modelling_functions.o] Error 1
ERROR: compilation failed for package ‘RMINC’
* removing ‘/home/povalag/R/x86_64-pc-linux-gnu-library/4.3/RMINC’
Warning message:
In i.p(...) :
  installation of package ‘/tmp/RtmpHh9zPL/file18e9121e5e30/RMINC_1.5.3.0.tar.gz’ had non-zero exit status
bcdarwin commented 1 year ago

At a quick glance, it looks like the R bindings to Fortran and/or Lapack might have changed in R 4.3 -- maybe try with 4.1 (possibly 4.2) if you haven't already?

gdevenyi commented 1 year ago

From the 4.3 changelog:

The included LAPACK sources have been updated to include the four Fortran 90 routines rather than their Fortran 77 predecessors. This may give some different signs in SVDs or eigendecompositions.. (This completes the transition to LAPACK 3.10.x begun in R 4.2.0.)

If RMINC is calling these the calling conventions have likely changed.

yohanyee commented 1 year ago

Fixed in https://github.com/Mouse-Imaging-Centre/RMINC/pull/315/commits/2d08d6e9b3f89761ccd3c9a050143041668adb72 . See commit message for more details on the issue (it has to do with how Fortran and C handle character strings, and a package-breaking update in R 4.3). I've submitted a pull request.

guilhermepovala commented 1 year ago

Thank you!

It worked with 4.1. Looking forward to have 2d08d6e incorporated.

yizhenxu commented 11 months ago

https://github.com/Mouse-Imaging-Centre/RMINC/commit/2d08d6e9b3f89761ccd3c9a050143041668adb72

This really works. THANK YOU SO MUCH. The documentation is in Writing R Extensions section 6.6.1 last paragraph. The change is absolutely needed for packages that use Lapack functions under R version 4.3.x. The documentation isn't at its fullest; it seems that the definition of FCONE has to be after any R_ext header and before any other R headers. The order matters, which is kinda awkward...