Unable to install 'gmp' package

Hi all. I'm attempting to use the 'CVXR' package for optimization problems, but need to have the 'gmp' package installed first, which fails to install.

When I attempt to install 'gmp' using install.packages("gmp"), I receive the below error:

configure: error: Header file gmp.h not found; maybe use --with-gmp-include=INCLUDE_PATH
ERROR: configuration failed for package ‘gmp’

This error prompted me to look through the 'gmp' download available at https://gmplib.org/, but could not locate the gmp.h header file noted above.

I am trying to install this in my R Studio server environment. Curiously enough, I was able to successfully install both 'gmp' and 'CVXR' on my local machine without an issue. This prompted me to look through the 'gmp' files that were installed on the local machine. I could not locate gmp.h there either. I tried to simply copy the files of that installation over to my server environment and run library('gmp'), but that was again unsuccessful and produced the below error:

Error: package or namespace load failed for ‘gmp’ in library.dynam(lib, package, package.lib):
 shared object ‘gmp.so’ not found

I'm out of ideas and would appreciate some direction. Thank you.

If your R Studio server is running Ubuntu or Linux Mint, try installing the libgmp-dev package on it.

Thanks Paul - this worked. I was able to install gmp by first installing libgmp-dev, then needed a few other root installations to finally install CVXR.

FWIW, you can use the pak package to see which system packages you need:

❯ pak::pkg_sysreqs("CVXR", sysreqs_platform = "ubuntu-22.04")
✔ Loading metadata database ... done
── Install scripts ───────────────────────────────────────────── Ubuntu 22.04 ──
apt-get -y update
apt-get -y install make libgmp3-dev libmpfr-dev

── Packages and their system dependencies ──────────────────────────────────────
ECOSolveR – make
gmp       – libgmp3-dev
Rmpfr     – libgmp3-dev, libmpfr-dev
scs       – make

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.