我正在尝试在 R 中安装 pgmm 库的特定版本,但它失败了:
> library(fs)
> old_lib <- path_home_r("R/x86_64-pc-linux-gnu-library/old-versions/")
> library(remotes)
> install_version("pgmm", version = "1.1", lib = old_lib, build = TRUE)
Downloading package from url: https://cloud.r-project.org/src/contrib/Archive/pgmm/pgmm_1.1.tar.gz
Running `R CMD build`...
* checking for file ‘/tmp/Rtmp6Jj3B0/remotes3b5e8d11b5fe/pgmm/DESCRIPTION’ ... OK
* preparing ‘pgmm’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* looking to see if a ‘data/datalist’ file should be added
* building ‘pgmm_1.1.tar.gz’
* installing *source* package ‘pgmm’ ...
** using staged installation
** libs
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-PsrVor/r-base-4.0.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c aecm.c -o aecm.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-PsrVor/r-base-4.0.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gaussj.c -o gaussj.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-PsrVor/r-base-4.0.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c myalloc.c -o myalloc.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-PsrVor/r-base-4.0.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c pgmm.c -o pgmm.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-PsrVor/r-base-4.0.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c updates.c -o updates.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o pgmm.so aecm.o gaussj.o myalloc.o pgmm.o updates.o -L/usr/lib/R/lib -lR
/usr/bin/ld: gaussj.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:4: multiple definition of `testfunc2'; aecm.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:4: first defined here
/usr/bin/ld: gaussj.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:1: multiple definition of `testfunc'; aecm.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:1: first defined here
/usr/bin/ld: myalloc.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:4: multiple definition of `testfunc2'; aecm.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:4: first defined here
/usr/bin/ld: myalloc.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:1: multiple definition of `testfunc'; aecm.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:1: first defined here
/usr/bin/ld: pgmm.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:4: multiple definition of `testfunc2'; aecm.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:4: first defined here
/usr/bin/ld: pgmm.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:1: multiple definition of `testfunc'; aecm.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:1: first defined here
/usr/bin/ld: updates.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:4: multiple definition of `testfunc2'; aecm.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:4: first defined here
/usr/bin/ld: updates.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:1: multiple definition of `testfunc'; aecm.o:/tmp/RtmpGlEBF9/R.INSTALL3b70d1f18017d/pgmm/src/functions.h:1: first defined here
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:6: pgmm.so] Error 1
ERROR: compilation failed for package ‘pgmm’
* removing ‘/home/eric/R/x86_64-pc-linux-gnu-library/old-versions/pgmm’
Warning message:
In i.p(...) :
installation of package ‘/tmp/Rtmp6Jj3B0/file3b5e87e350a98/pgmm_1.1.tar.gz’ had non-zero exit status
“R/x86_64-pc-linux-gnu-library/old-versions/”目录存在,1.1版本的pgmm包也存在。非常感谢任何修复建议。
在 Ubuntu 20.10 上,可以使用 gcc-9 安装 pgmm 1.1:
然后编译R包。
要将 gcc 版本恢复为默认使用以下命令:
该问题与 R pgmm 的特定版本无关,而是与任何不符合编写 R 扩展指南的 R 扩展有关:1.6.4.1使用 GCC 10 及更高版本构建时的常见符号。
我们可以演示使用
functions.h
从 复制pgmm/src
的最小文件,以及两个包含它的最小 C 源文件:然后使用 GCC 10,使用默认值
-fno-common
:而与
-fcommon
解决方案是使用旧版本的 GCC 构建,或者自定义 R 构建过程,如R 安装和管理中所述:6.3.3 自定义包编译
-fcommon
以通过CFLAGS
变量传递选项。也可以看看: