I am trying to install a specific version fo the pgmm library in R, and it fails:
> 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
The "R/x86_64-pc-linux-gnu-library/old-versions/"-directory exists and the 1.1 version of the pgmm package also exists. Any suggestion for fix greatly appreciated.
On Ubuntu 20.10 it is possible to install pgmm 1.1 using gcc-9:
and then compile R package.
To revert the gcc version to default use command below:
The issue is not related to the specific version of R pgmm, but to any R extension that fails to comply with the guidelines Writing R Extensions: 1.6.4.1 Common symbols when building using GCC 10 and above.
We can demonstrate using a minimal
functions.h
copied frompgmm/src
, plus a couple of minimal C source files that both include it:Then with GCC 10, using the default
-fno-common
:whereas with
-fcommon
The solution is either to build using an older version of GCC, or to customize your R build process as explained in R Installation and Administration: 6.3.3 Customizing package compilation to pass option
-fcommon
via theCFLAGS
variable.See also: