How to fix R package installation fatal error: zlib.h: No such file or directory

Problem:

While installing some R package, you see an error message like

example.txt
io_utils.c:16:10: fatal error: zlib.h: No such file or directory
   16 | #include <zlib.h>
      |          ^~~~~~~~
compilation terminated.
make: *** [/usr/lib/R/etc/Makeconf:168: io_utils.o] Error 1

Solution

You need to install the zlib development headers. On Ubuntu, you can do that using

example.sh
sudo apt -y install zlib1g-dev

 


Check out similar posts by category: R