在 R 包中使用 -fPIC 重新编译

Recompile with -fPIC in R package

我试图在 R 中安装 imager 包,但遇到以下错误:

/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’
* removing ‘/home/tjcooper/R/x86_64-pc-linux-gnu-library/4.0/imager’
Warning in install.packages :
  installation of package ‘imager’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpZagOIF/downloaded_packages’

即共享库和静态库之间的一些问题。我不太确定如何解决这个问题 - 有什么想法吗?

R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_IL.UTF-8       LC_NUMERIC=C               LC_TIME=en_IL.UTF-8        LC_COLLATE=en_IL.UTF-8     LC_MONETARY=en_IL.UTF-8    LC_MESSAGES=en_IL.UTF-8    LC_PAPER=en_IL.UTF-8      
 [8] LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_IL.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] SummarizedExperiment_1.20.0 Biobase_2.50.0              GenomicRanges_1.42.0        GenomeInfoDb_1.26.0         IRanges_2.24.0              S4Vectors_0.28.0           
[7] BiocGenerics_0.36.0         MatrixGenerics_1.2.0        matrixStats_0.57.0         

loaded via a namespace (and not attached):
  [1] bitops_1.0-6           GSVA_1.38.0            enrichplot_1.10.0      dynutils_1.0.5         bit64_4.0.5            RColorBrewer_1.1-2     httr_1.4.2             tools_4.0.3           
  [9] R6_2.5.0               irlba_2.3.3            DBI_1.1.0              colorspace_2.0-0       tidyselect_1.1.0       gridExtra_2.3          proxyC_0.1.5           bit_4.0.4             
 [17] compiler_4.0.3         graph_1.68.0           scatterpie_0.1.5       DelayedArray_0.16.0    shadowtext_0.0.7       scales_1.1.1           stringr_1.4.0          digest_0.6.27         
 [25] DOSE_3.16.0            XVector_0.30.0         pkgconfig_2.0.3        rlang_0.4.8            rstudioapi_0.13        RSQLite_2.2.1          farver_2.0.3           generics_0.1.0        
 [33] BiocParallel_1.24.1    GOSemSim_2.16.1        dplyr_1.0.2            RCurl_1.98-1.2         magrittr_1.5           GO.db_3.12.1           GenomeInfoDbData_1.2.4 Matrix_1.2-18         
 [41] Rcpp_1.0.5             dyndimred_1.0.3        munsell_0.5.0          viridis_0.5.1          lifecycle_0.2.0        stringi_1.5.3          ggraph_2.0.3           MASS_7.3-53           
 [49] zlibbioc_1.36.0        plyr_1.8.6             qvalue_2.22.0          grid_4.0.3             blob_1.2.1             ggrepel_0.8.2          DO.db_2.9              crayon_1.3.4          
 [57] lattice_0.20-41        cowplot_1.1.0          graphlayouts_0.7.1     splines_4.0.3          annotate_1.68.0        pillar_1.4.6           fgsea_1.16.0           igraph_1.2.6          
 [65] codetools_0.2-16       reshape2_1.4.4         fastmatch_1.1-0        XML_3.99-0.5           glue_1.4.2             downloader_0.4         BiocManager_1.30.10    data.table_1.13.2     
 [73] remotes_2.2.0          RcppParallel_5.0.2     foreach_1.5.1          tweenr_1.0.1           vctrs_0.3.4            polyclip_1.10-0        gtable_0.3.0           purrr_0.3.4           
 [81] tidyr_1.1.2            assertthat_0.2.1       ggplot2_3.3.2          ggforce_0.3.2          xfun_0.19              lmds_0.1.0             xtable_1.8-4           tidygraph_1.2.0       
 [89] viridisLite_0.3.0      tibble_3.0.4           pheatmap_1.0.12        iterators_1.0.13       rvcheck_0.1.8          clusterProfiler_3.18.0 tinytex_0.27           AnnotationDbi_1.52.0  
 [97] memoise_1.1.0          gam_1.20               ellipsis_0.3.1         GSEABase_1.52.0  

 

这通常意味着您要使用的库,此处 libfftw3 构建方式有误。第一个偏好是作为共享库创建 libfftw3.so。第二个首选是静态库 libftw3.a ,但带有 -fPIC 可重定位代码的编译选项 。此处缺少,正是错误消息所暗示的内容。

一个我的 (Ubuntu) 系统它来对了:

$ file /usr/lib/x86_64-linux-gnu/libfftw3.so
/usr/lib/x86_64-linux-gnu/libfftw3.so: symbolic link to libfftw3.so.3.5.8
$ file /usr/lib/x86_64-linux-gnu/libfftw3.so.3.5.8 
/usr/lib/x86_64-linux-gnu/libfftw3.so.3.5.8: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=56a87c8c86308035675bfd1c10d09c29b5450bc7, stripped
$ 

您需要修复该问题,然后尝试重新安装 imager

None顺便跟Rcpp有关系

编辑 因为你也在Ubuntu,就这样做:

sudo apt install libfftw3-dev

但还要删除 /usr/local 下面的安装,因为它会影响系统安装。然后重新安装任何使用 fftw3 的东西,包括 imager.