为什么在Ubuntu 20.04上成功安装FFTW 3.3.10后,R包fftwtools的安装失败

  • 本文关键字:安装 失败 fftwtools FFTW Ubuntu 成功 r
  • 更新时间 :
  • 英文 :


我的目标是安装R包"fftwtools";在我的电脑上安装了Ubuntu 20.04作为唯一的操作系统。在阅读了之前关于stackoverflow的帖子后,我安装了最新版本的fftw(3.3.10(,包括使用的开发版本

sudo apt-get install fftw3-dev

我可以在/usr/local/lib中看到如下库文件:

dorazio@toucan:/usr/local/lib$ ls -la
total 3640
drwxr-xr-x  7 root root     4096 Feb 27 10:53 .
drwxr-xr-x 10 root root     4096 Apr 27  2018 ..
drwxr-xr-x  3 root root     4096 Feb 27 10:52 cmake
-rw-r--r--  1 root root  3581658 Feb 27 10:52 libfftw3.a
-rwxr-xr-x  1 root root      888 Feb 27 10:52 libfftw3.la
-rw-r--r--  1 root root    46990 Feb 27 10:53 libfftw3_omp.a
-rwxr-xr-x  1 root root      936 Feb 27 10:53 libfftw3_omp.la
-rw-r--r--  1 root root    52098 Feb 27 10:53 libfftw3_threads.a
-rwxr-xr-x  1 root root      948 Feb 27 10:53 libfftw3_threads.la
drwxr-xr-x  2 root root     4096 Feb 27 10:52 pkgconfig
drwxrwsr-x  4 root staff    4096 Mar 13  2021 python2.7
drwxrwsr-x  3 root staff    4096 Aug  3  2020 python3.8
drwxrwsr-x  3 root staff    4096 May 26  2018 R

然而,在尝试安装R包fftwtools时,我收到以下错误消息:

R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> 
> install.packages('fftwtools')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/fftwtools_0.9-11.tar.gz'
Content type 'application/x-gzip' length 174321 bytes (170 KB)
==================================================
downloaded 170 KB
* installing *source* package ‘fftwtools’ ...
** package ‘fftwtools’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc -std=gnu99 -std=gnu11
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 -std=gnu99 -std=gnu11 accepts -g... yes
checking for gcc -std=gnu99 -std=gnu11 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -std=gnu11 -E
checking for gcc... (cached) gcc -std=gnu99 -std=gnu11
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc -std=gnu99 -std=gnu11 accepts -g... (cached) yes
checking for gcc -std=gnu99 -std=gnu11 option to accept ISO C89... (cached) none needed
checking for pkg-config... yes
configure: creating ./config.status
config.status: creating src/Makevars
fftwtools 0.9-10
================
compiler flags: -I/usr/local/include 
link argument:  -L/usr/local/lib -lfftw3 
** libs
gcc -std=gnu99 -std=gnu11 -I"/usr/share/R/include" -DNDEBUG -I/usr/local/include        -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-i2PIHO/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c fftwtools.c -o fftwtools.o
gcc -std=gnu99 -std=gnu11 -I"/usr/share/R/include" -DNDEBUG -I/usr/local/include        -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-i2PIHO/r-base-4.1.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c fftwtools_init.c -o fftwtools_init.o
gcc -std=gnu99 -std=gnu11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o fftwtools.so fftwtools.o fftwtools_init.o -L/usr/local/lib -lfftw3 -L/usr/lib/R/lib -lR
/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: fftwtools.so] Error 1
ERROR: compilation failed for package ‘fftwtools’
* removing ‘/usr/local/lib/R/site-library/fftwtools’
The downloaded source packages are in
‘/tmp/Rtmp4FsjOe/downloaded_packages’
Warning message:
In install.packages("fftwtools") :
installation of package ‘fftwtools’ had non-zero exit status
> 

根据Karim的建议,我从tarball fftw-3.3.10.tar.gz构建了fftw,如下所示:

./configure --enable-threads --enable-openmp --enable-avx
make
make install

这在/usr/local/lib:中创建了几个libfftw3*.*文件

drwxr-xr-x  7 root root     4096 Feb 27 10:53 .
drwxr-xr-x 10 root root     4096 Apr 27  2018 ..
drwxr-xr-x  3 root root     4096 Feb 27 10:52 cmake
-rw-r--r--  1 root root  3581658 Feb 27 10:52 libfftw3.a
-rwxr-xr-x  1 root root      888 Feb 27 10:52 libfftw3.la
-rw-r--r--  1 root root    46990 Feb 27 10:53 libfftw3_omp.a
-rwxr-xr-x  1 root root      936 Feb 27 10:53 libfftw3_omp.la
-rw-r--r--  1 root root    52098 Feb 27 10:53 libfftw3_threads.a
-rwxr-xr-x  1 root root      948 Feb 27 10:53 libfftw3_threads.la
drwxr-xr-x  2 root root     4096 Feb 27 10:52 pkgconfig
drwxrwsr-x  4 root staff    4096 Mar 13  2021 python2.7
drwxrwsr-x  3 root staff    4096 Aug  3  2020 python3.8
drwxrwsr-x  3 root staff    4096 May 26  2018 R

然后我尝试从CRAN安装fftwtools,但这产生了与我最初发布的错误消息相同的错误消息。

c2d4u("CRAN to Deb(ian(-适用于Ubuntu"(repo有一个二进制文件。在CRAN的Ubuntu自述中介绍了如何设置。

我维护了一个特定的Rocker容器变体,它将R自己的install.packages连接起来,以便在可用的情况下使用这些二进制文件(它依赖于bspm包(,它只是根据install.packages("fftwtools")的请求转换为二进制文件r-cran-fftwtools_0.9-11-1cran1.2004.0_amd64.deb的安装(适用于Ubuntu 20.04(,并负责所有依赖项。

您可以通过两个或三个命令来复制这一点(使用Docker(

docker run --rm -ti rocker/r-bspm:20.04 bash

以启动容器,并启动bashshell。然后我更新索引并要求安装:

apt update -qq
Rscript -e 'install.packages("fftwtools")'

这能解决所有问题。完整日志:

edd@rob:~$ docker run --rm -ti rocker/r-bspm:20.04 bash
root@14a6fb8a9329:/# apt update -qq
31 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@14a6fb8a9329:/# Rscript -e 'install.packages("fftwtools")'
Loading required package: utils
Tracing function "install.packages" in package "utils"
Install system packages as root...
Reading package lists... Done
Building dependency tree        
Reading state information... Done
Hit http://security.ubuntu.com/ubuntu focal-security InRelease                                                                                                                                                    
Hit http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal InRelease                                                                                                                                          
Hit http://archive.ubuntu.com/ubuntu focal InRelease                                                                                                                                                              
Hit http://archive.ubuntu.com/ubuntu focal-updates InRelease                                                                                                                                                      
Hit http://ppa.launchpad.net/edd/r-4.0/ubuntu focal InRelease                                                                                                                                                     
Hit http://archive.ubuntu.com/ubuntu focal-backports InRelease                                                                                                                                                    
Hit http://ppa.launchpad.net/marutter/rrutter4.0/ubuntu focal InRelease                                                                                                                                           
Fetched 0 B in 0s (0 B/s)                                                                                                                                                                                         
Reading package lists... Done    
Building dependency tree          
Reading state information... Done
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libfftw3-double3 amd64 3.3.8-2ubuntu1 [728 kB]                                                                                                            
Get:2 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal/main amd64 r-cran-fftwtools amd64 0.9-11-1cran1.2004.0 [167 kB]                                                                                  
Fetched 895 kB in 0s (0 B/s)                                                                                                                                                                                      
Selecting previously unselected package libfftw3-double3:amd64.
(Reading database ... 20688 files and directories currently installed.)
Preparing to unpack .../libfftw3-double3_3.3.8-2ubuntu1_amd64.deb ...
Unpacking libfftw3-double3:amd64 (3.3.8-2ubuntu1) ...
Selecting previously unselected package r-cran-fftwtools.
Preparing to unpack .../r-cran-fftwtools_0.9-11-1cran1.2004.0_amd64.deb ...
Unpacking r-cran-fftwtools (0.9-11-1cran1.2004.0) ...
Setting up libfftw3-double3:amd64 (3.3.8-2ubuntu1) ...
Setting up r-cran-fftwtools (0.9-11-1cran1.2004.0) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
root@14a6fb8a9329:/# 

现在,这些都不依赖Docker,我只是把它当作一个演示。如果您按照上面链接的README.md上的描述连接"c2d4u.team"repo,则可以执行标准sudo apt install r-cran-fftwtool。如果您愿意,您也可以查看bspm,使其可以通过install.packages()从R访问,但这实际上只是一个额外的功能。

请在r-sig-debian列表中提出任何具体问题。

我以前从未遇到过这个问题,但为了适应多个系统,已经更新了构建文件。

你能试着用柏油路建造fftw吗?

因此,删除ubuntu包,然后从tarball中安装fftw,如果您遇到同样的错误,请告诉我。

http://www.fftw.org/download.html

最美好的祝愿,

我遇到了同样的错误,我还不想升级到R4。但是,使用命令sudo apt-get install libfftw3-dev安装这个库libfftw3-dev解决了这个问题。

最新更新