Search code examples
rheatmapcairo

R, issue "unable to load shared object cairo.so" on Linux CentOS 7


I've been using R with ggplot2 and other packages on my Linux CentOS 7 for a long time. Today, all of a sudden, it stopped working.

When I call the png() function in my script, it generates the following errrors:

Warning messages:
1: In png(heatmap_file) :
  unable to load shared object '/usr/lib64/R/library/grDevices/libs//cairo.so':
  /lib64/libcairo.so.2: undefined symbol: FT_Get_Var_Design_Coordinates
2: In png(heatmap_file) : failed to load cairo DLL

I tried to update the cairo package many times but nothing worked out so far. What can I do?

Thanks!


Solution

  • I found a solution and I am going to share it with the community.

    I am working on a Dell Latitude 3540 laptop running Linux CentOS 7 operating system (centos-release-7-3.1611.el7.centos.x86_64).

    I ran sudo yum -y update and I understood there was a duplication issue regarding the freetype package, which was installed twice, and some other packages that were having conflicts.

    I then removed the old freetype package and the conflicting packages with this command:

    rpm -e freetype-2.4.11-12.el7.i686 --nodeps
    rpm -e conflicting-package-1 --nodeps
    rpm -e conflicting-package-2 --nodeps
    ...
    

    Then I updated all the packages I manually removed:

    sudo yum -y update freetype
    sudo yum -y conflicting-package-1 freetype
    sudo yum -y conflicting-package-2 freetype
    ...
    

    This method worked out for me; I hope it might be helpful to someone.