Install imager package in Ubuntu with fftw

Install the last version of fftw to have full possibilities of imager package:
Go directly at the end of that post to have the solution !


Check the last version of  fftw here http://www.fftw.org
wget http://www.fftw.org/fftw-3.3.10.tar.gz
tar -xf fftw-3.3.10.tar.gz
cd fftw-3.3.10
./configure
make
sudo make install
cd ..
rm fftw-3.3.10.tar.gz
rm -r fftw-3.3.10

then in R
install.packages("imager")

It fails with imager 1.0.1 with the following error :
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -o imager.so RcppExports.o colourspace.o coordinates.o display.o drawing.o filtering.o hough.o imgraphs.o interact.o interpolation.o morphology.o reductions.o transformations.o utils.o wrappers.o -fopenmp -lX11 -Dcimg_use_fftw3 -L/usr/local/lib -lfftw3 -ltiff -L/usr/lib/R/lib -lR
/usr/bin/ld: /usr/local/lib/libfftw3.a(assert.o): warning: relocation against `stdout@@GLIBC_2.2.5' in read-only section `.text'
/usr/bin/ld: /usr/local/lib/libfftw3.a(assert.o): relocation R_X86_64_PC32 against symbol `stdout@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:10: imager.so] Error 1
ERROR: compilation failed for package ‘imager’


The reason is explained below by the author of the imager package:
"You have an fftw library under /use/local that you probably compiled yourself? That one is being picked, but it doesn't have a shared library, only a static one, and that fails to link.

You could try removing your custom libfftw installation, or if you really need that particular version then try compiling and installing the shared library version next to (or instead of) the static one."

I remove the fftw library by:

wget http://www.fftw.org/fftw-3.3.10.tar.gz
tar -xf fftw-3.3.10.tar.gz
cd fftw-3.3.10
./configure
make
sudo make uninstall

Then the compilation of imager works but with the following warning:

checking for FFTW... no

FFTW library not found, please install fftw3 for better FFT support.


The solution is to install fftw with the --enable-shared option (it was not necessary to remove the previous installation of fftw):

wget http://www.fftw.org/fftw-3.3.10.tar.gz
tar -xf fftw-3.3.10.tar.gz
cd fftw-3.3.10
./configure --enable-shared
make
sudo make install
cd ..
rm fftw-3.3.10.tar.gz
rm -r fftw-3.3.10

then in R
install.packages("imager")

And all is ok !

Thanks to the author of the imager package for his help.

Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04