4

When trying to install the R gmp package, the installation fails because of the following error: configure: error: Header file gmp.h not found

the whole log:

> installing *source* package 'gmp' ...
> package 'gmp' successfully unpacked and MD5 sums checked
> using staged installation
> checking for gcc... gcc
> checking whether the C compiler works... yes
> checking for C compiler default output file name... a.out
> checking for suffix of executables...
> checking whether we are cross compiling... no
> checking for suffix of object files... o
> checking whether we are using the GNU C compiler... yes
> checking whether gcc accepts -g... yes
> checking for gcc option to accept ISO C89... none needed
> checking how to run the C preprocessor... gcc -E
> checking whether we are using the GNU C++ compiler... yes
> checking whether g++ -std=gnu++11 accepts -g... yes
> checking for grep that handles long lines and -e... /usr/bin/grep
> checking for egrep... /usr/bin/grep -E
> checking for ANSI C header files... yes
> checking for sys/types.h... yes
> checking for sys/stat.h... yes
> checking for stdlib.h... yes
> checking for string.h... yes
> checking for memory.h... yes
> checking for strings.h... yes
> checking for inttypes.h... yes
> checking for stdint.h... yes
> checking for unistd.h... yes
> checking gmp.h usability... no
> checking gmp.h presence... no
> checking for gmp.h... no
> configure: error: Header file gmp.h not found; maybe use --with-gmp-include=INCLUDE_PATH
> ERROR: configuration failed for package 'gmp'`

I found a lot of questions concerning finding the gmp.h file, but non were usable for my case because I am working on a remote server and I am not a root user, meaning I cannot just install whatever I want.

I tried the installation using both the terminal and the R shell but both gave the same error.

BlS
  • 55
  • 4
  • 5
    It seems likely that you don't have the underlying dev package installed. If you look at the package `DESCRIPTION` (such as [CRAN](https://cran.r-project.org/web/packages/gmp/index.html)'s page), it says `SystemRequirements: gmp (>= 4.2.3)`, which typically means that there is a (non-R) OS package/library required in order to compile and/or use this package. With a little research, one could find reference to `libgmp` (in its source too). On ubuntu, for instance, `sudo apt-get install -y libgmp-dev` may suffice, not certain about RPM-based distros. – r2evans Nov 09 '22 at 13:04
  • Alternatively, you can use the package repo provided by Posit (formerly RStudio) at https://packagemanager.rstudio.com/client/#/repos/1/overview or https://packagemanager.posit.co/client/#/repos/1/overview. It provides binary packages for most OSes, as opposed to CRAN which provides binaries for only select (typically not unix-y) OSes. – r2evans Nov 09 '22 at 13:06
  • @r2evans, thank you for your answer, but as I mentioned I am not a root user on the system I am working on. I do not have the rights to execute sudo commands, that solution won't work for me... – BlS Nov 09 '22 at 13:36
  • If you cannot install `libgmp10` or `libgmp-dev`, then there's nothing in the world you can do to use the `gmp` package which requires the latter to compile and the former to run. Ask your sysadmin to install at least `libgmp10`, then you can use Posit's packagemanager. Lacking that, perhaps you can find a similar unix-y system that has `/usr/lib/x86_64-linux-gnu/libgmp.so` and copy that into a local directory on this system (and then restart R and use Posit's packagemanager). Options. – r2evans Nov 09 '22 at 13:40
  • 2
    In R, run `list.files(strsplit(Sys.getenv("LD_LIBRARY_PATH"), ":")[[1]], pattern = "libgmp\\..*", full.names=TRUE)`. If it returns something, then you should be able to use Posit'x packagemanager for a binary package install. If it returns nothing (`character(0)`), then you need to find a `libgmp.so` from a similarly-configured unix-y system that you can copy into your local directory; for that, it may help if you provide the output from `system("uname -a")`. – r2evans Nov 09 '22 at 13:47
  • 1
    what is your operating system? Is a binary version available (e.g. for ubuntu see https://launchpad.net/~c2d4u.team/+archive/ubuntu/c2d4u4.0+/+packages?field.name_filter=gmp&field.status_filter=published&field.series_filter=). Then install it without root (https://askubuntu.com/questions/339/how-can-i-install-a-package-without-root-access) – user20650 Nov 09 '22 at 14:58

1 Answers1

2

dnf install gmp-devel or apt-get install libgmp-dev worked for me