1

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.

8
  • What are - your Ubuntu version, R version, R origin? – N0rbert May 20 at 18:54
  • Ubuntu 20.10, R version 4.0.2, installs from the CRAN repository. _ – ElToro1966 May 20 at 19:05
  • BTW: install_version("pgmm", version = "1.2.4", lib = old_lib, build = TRUE) works. 1.2.4 is the latest version. However, I wanted 1.1. – ElToro1966 May 20 at 19:19
  • 1
    .What is your gcc version? I wonder if it could be gcc-10's new default -fno-common option? See for example Porting to GCC 10 – steeldriver May 20 at 19:38
  • 1
    I can reproduce on 20.10. Maybe it is 7 years of some changes. It normally compiles on 18.04 LTS with R 3.4.4 and on 20.04 LTS with R 3.6. – N0rbert May 20 at 19:39
2

On Ubuntu 20.10 it is possible to install pgmm 1.1 using gcc-9:

sudo apt-get install gcc-9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9

and then compile R package.

To revert the gcc version to default use command below:

sudo update-alternatives --remove-all gcc
1
  • Yup. Worked! Thanks oh so very much! I was running myself ragged with this problem. – ElToro1966 May 21 at 9:17
1

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 from pgmm/src, plus a couple of minimal C source files that both include it:

$ head functions.h A.c B.c
==> functions.h <==
double (*testfunc)(double **, double **, int *,int,int,int,int,double *,double *,double);
typedef typeof(testfunc) funcType;

double (*testfunc2)(double **, double **,int,int,int,int,double *,double *,double);
typedef typeof(testfunc2) funcType2;

==> A.c <==
#include "functions.h"

==> B.c <==
#include "functions.h"

Then with GCC 10, using the default -fno-common:

$ make CC=gcc-10 A.o B.o
gcc-10    -c -o A.o A.c
gcc-10    -c -o B.o B.c
$ gcc -shared A.o B.o && echo "OK" || echo "FAILED"
/usr/bin/ld: B.o:(.bss+0x0): multiple definition of `testfunc'; A.o:(.bss+0x0): first defined here
/usr/bin/ld: B.o:(.bss+0x8): multiple definition of `testfunc2'; A.o:(.bss+0x8): first defined here
collect2: error: ld returned 1 exit status
FAILED

whereas with -fcommon

$ rm *.o
$ make CC=gcc-10 CFLAGS=-fcommon A.o B.o
gcc-10 -fcommon   -c -o A.o A.c
gcc-10 -fcommon   -c -o B.o B.c
$ gcc -shared A.o B.o && echo "OK" || echo "FAILED"
OK
$

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 the CFLAGS variable.

See also:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.