1

I am try to install the hdp package by Nicola Robers using the following command in R:

devtools::install_github("nicolaroberts/hdp", build_vignettes = TRUE)

This used to get compiled and installed fine when I had the R version 3.6.2 and gcc version 9.2.1 on an (Arch) Linux machine. After updating the system to R 4.0.0 and gcc 10.1.0, the installation fails with the following message:

* installing *source* package ‘hdp’ ...
** using staged installation
** libs
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-base.c -o R-base.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-conparam.c -o R-conparam.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-dp.c -o R-dp.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-hdp.c -o R-hdp.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-hdpMultinomial_iterate.c -o R-hdpMultinomial_iterate.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-multinomial.c -o R-multinomial.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c R-utils.c -o R-utils.o
gcc -I"/usr/include/R/" -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -c randutils.c -o randutils.o
gcc -shared -L/usr/lib64/R/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -o hdp.so R-base.o R-conparam.o R-dp.o R-hdp.o R-hdpMultinomial_iterate.o R-multinomial.o R-utils.o randutils.o -L/usr/lib64/R/lib -lR
/usr/bin/ld: R-conparam.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
/usr/bin/ld: R-dp.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
/usr/bin/ld: R-hdp.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
/usr/bin/ld: R-hdpMultinomial_iterate.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
/usr/bin/ld: R-multinomial.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
/usr/bin/ld: R-utils.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
/usr/bin/ld: randutils.o:(.bss+0x0): multiple definition of `DEBUG'; R-base.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R//make/shlib.mk:6: hdp.so] Error 1
ERROR: compilation failed for package ‘hdp’

The individual files are compiling fine, but the linking seems to fail. Any idea on how to go about debugging what is missing?

asked May 29, 2020 at 1:44

2 Answers 2

2

I had the same issue and ended up wrangling with the C code for several hours. My knowledge in C/C++ is very limited so perhaps there are better solutions but these changes worked for me.

  1. Defining NODEBUG in R-utils.h after #ifndef NODEBUG and adding an extern to the declaration of DEGUB per below.
#ifndef NODEBUG
#define NODEBUG
extern int DEBUG;
  1. Added int DEBUG to R-utils.c after #include "R-utils.h".
answered Mar 29, 2022 at 21:50
Sign up to request clarification or add additional context in comments.

Comments

1

In case someone else runs into this issue: I manged to compile it by commenting all the references to the debug printing code. I commented all lines with rdebug* and DEBUG. These functions are mainly defined in R-utils.h. It still would be nice to find a better solution. There seems to be a circular definition of the DEBUG?

answered May 30, 2020 at 20:22

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.