ANTsX / ANTsR

R interface to the ANTs biomedical image processing library
https://antsx.github.io/ANTsR
Apache License 2.0
127 stars 35 forks source link

installation problem antsLibs() Makevars:6: *** missing separator. Stop. #368

Closed boboshaq closed 1 year ago

boboshaq commented 2 years ago

Describe the bug Hi, I have problem to install ANTsR. Installation stops with error:

Makevars:6: *** missing separator.  Stop.
ERROR: compilation failed for package 'ANTsR

To Reproduce Steps to reproduce the behavior:

  1. R
  2. library( devtools )
  3. install_github("stnava/ANTsR")

I was previous installed cmaker and ANTsCore.

> library( devtools )
Loading required package: usethis
> install_github("stnava/ANTsR")
Downloading GitHub repo stnava/ANTsR@HEAD
v  checking for file '/tmp/RtmpdPe9KQ/remotes1b62415569046/ANTsX-ANTsR-3bdd020/DESCRIPTION' (354ms)
-  preparing 'ANTsR':
v  checking DESCRIPTION meta-information ...
-  cleaning src
-  running 'cleanup'
-  checking for LF line-endings in source and make files and shell scripts (338ms)
-  checking for empty or unneeded directories
-  building 'ANTsR_0.5.7.5.tar.gz'

* installing *source* package 'ANTsR' ...
** using staged installation
linux-gnu 0
** libs
Makevars:6: *** missing separator.  Stop.
ERROR: compilation failed for package 'ANTsR'
* removing '/path/to/R/4.2.1/lib64/R/library/ANTsR'
Warning message:
In i.p(...) :
  installation of package '/tmp/RtmpdPe9KQ/file1b624660ada9c/ANTsR_0.5.7.5.tar.gz' had non-zero exit status

My ~/.R/Makevars file:

CXX14=g++

From configure script I have know that above error touch different Makevars file : $ANTsR_HOME/src/Makevars and this is what it contain:

myantssource=${PWD}/ants/
ITK=/path/to/R/4.2.1/lib64/R/library/ITKR/libs/include/ITK-5.3/
PKG_CPPFLAGS = -I${ITK} -I${PWD}    -I/path/to/R/4.2.1/lib64/R/library/ANTsRCore/include/   -I../inst/include/ 
CXX_STD = CXX14
myantslib=[1] "antsLibs: ants libs do not exist"
/path/to/R/4.2.1/lib64/R/library/ANTsRCore/libs/lib/
libants=`find [1] "antsLibs: ants libs do not exist"
/path/to/R/4.2.1/lib64/R/library/ANTsRCore/libs/lib/ -name "lib*.a"`
libitk=`find /path/to/R/4.2.1/lib64/R/library/ITKR/libs/lib/ -name "lib*.a"`
PKG_LIBS= ${libitk} ${libants} ${libitk} ${libants}   ${libitk} ${libants} ${libitk} ${libants}   ${libitk} ${libants} ${libitk} ${libants}   ${libitk} ${libants}
.PHONY: all libs
all: $(SHLIB)
$(SHLIB): libs
libs: ; cd ${PWD}

Those are problematic lines: *myantslib=[1] "antsLibs: ants libs do not exist" /path/to/R/4.2.1/lib64/R/library/ANTsRCore/libs/lib/ libants=`find [1] "antsLibs: ants libs do not exist" /path/to/R/4.2.1/lib64/R/library/ANTsRCore/libs/lib/ -name "lib.a"`**

From configure script we know that myantslib use antsLibs() function:

[69] myantslib=`${R_HOME}/bin/Rscript -e 'a<-ANTsRCore:::antsLibs(); cat(a)'`

[71] # echo "myantslib=`\${R_HOME}/bin/Rscript -e 'ANTsRCore:::antsLibs()'` " >> Makevars
[72] echo "myantslib=${myantslib}" >> Makevars

ANTsRCore:::antsLibs() - call this to get the path to ants static libaries to which you will link

In my environment, /path/to/R/4.2.1/lib64/R/library/ANTsRCore/libs does not contain lib folder:

ls /path/to/R/4.2.1/lib64/R/library/ANTsRCore/libs
ANTsRCore.so  lib64

and now variable libants from configure script:

[74] echo "libants=\`find ${myantslib} -name \"lib*.a\"\`" >> Makevars

Expected behavior I want to install ANTsR. What to do to installation pass?

Desktop (please complete the following information):

boboshaq commented 2 years ago

The same problem is when I install ANTsR in this way:

  1. git clone https://github.com/ANTsX/ANTsR.git
  2. R CMD INSTALL ANTsR

Before this problem occur I was problem with ANTsCORE installation. Only ITKR was installed sucessfully. I think that all problems are because I have installed several versions of gcc. In my system is 4.8.5 version but I may use 5.5.0 and 7.5.0 versions too. Originally installed version 4.8.5 is to old to install ITKR+ANTsCORE+ANTsR packages so I typically use 7.5.0 version. I have it in my PATH and lib64 path is in LD_LIBRARY_PATH variable . Regardless ANTsCORE and ANTsR use 4.8.5 version while inside R installation and in cmdline installation (R CMD INSTALL). They do not use ~/.R/Makevars file at all. In my case, to install ANTsCORE and ANTsR packages I had to export CXX and CC variable with pathes to 7.5.0 version of gcc before instalation begins (R CMD INSTALL ...)

anthonypj commented 1 year ago

I've been having the same issues on Centos 7. I've tried the drat, devtools and command line install options, and the following software versions:

R 3.5.3 and 4.1.2 cmake 2.8.12.2 and 3.17.5 gcc 4.8,5, 10.2.1, 11.2.1

Please let me know if you need further information, or need me to try anything

cookpa commented 1 year ago

Reproducible on CentOS with the latest ANTsR source, so I'm adding the bug label.

cookpa commented 1 year ago

I see some problems with library paths in ANTsRCore that may be the cause here. Working on a fix

cookpa commented 1 year ago

The issue was that ANTsRCore expected libraries under lib, while some distributions including Centos use lib64. It now checks both before printing an error message.

I'm now able to build ANTsR with R 4.2.3 and GCC 7.5.0 on Centos7.