davidgohel / rvg

https://davidgohel.github.io/rvg/
132 stars 15 forks source link

Compilation Error: 'png.h' file not found when installing 'rvg' package on macOS #55

Closed nakashimatakaya closed 2 weeks ago

nakashimatakaya commented 9 months ago

Hello,

I encountered a compilation error while attempting to install the rvg package on macOS after updated R version 4.3.2 (2023-10-31). Here is the error message I received:

`raster.cpp:6:10: fatal error: 'png.h' file not found

include

     ^~~~~~~

1 error generated. make: *** [raster.o] Error 1 ERROR: compilation failed for package ‘rvg’ `

This issue occurred during the installation process, indicating that the png.h header file could not be found. It seems like a dependency problem related to the libpng library, which is required for compiling the rvg package.

I have attempted to resolve this issue by ensuring that libpng is installed on my system, but the problem persists. Below are the steps I have taken:

Checked to ensure that libpng is installed and up to date.

I would greatly appreciate any advice on resolving this issue or any additional steps I should take to troubleshoot further.

Thank you for your help.

adamstefkovics commented 2 weeks ago

Hi, have you managed to solve this? Same issue here.

davidgohel commented 2 weeks ago

you need to install libpng

it depends on your platform and many more parameters (if you want to compile C code, you should be able to set up your platform 😛). For me, on macos, I used:

brew install libpng

Then I configured the file ~/.R/Makevars. Mine is actually this one:

LOC=/usr/local/Cellar/gcc/14.2.0_1
CC=$(LOC)/bin/gcc-14 -fopenmp
CXX=$(LOC)/bin/g++-14 -fopenmp
CXX11=$(LOC)/bin/g++-14 -fopenmp

CFLAGS=-I/usr/local/include
CPPFLAGS=-I/usr/local/include
CXXFLAGS=-I/usr/local/include
CXX11FLAGS=-I/usr/local/include
LDFLAGS=-L/usr/local/lib

You may need to adapt it, I don't know if you have gcc-14 for example

davidgohel commented 2 weeks ago

See https://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Using-Makevars

adamstefkovics commented 2 weeks ago

thanks so much, I'll try!