r-lib / svglite

A lightweight svg graphics device for R
https://svglite.r-lib.org
180 stars 39 forks source link

devSVG.cpp:21:10: fatal error: 'png.h' file not found #133

Closed brainprint closed 2 years ago

brainprint commented 3 years ago

Hi and thank you for your package. I have face this error today.

R version 4.0.3 (2020-10-10) macOS 11.2.1 - Intel svglite 2.0.0

devSVG.cpp:21:10: fatal error: 'png.h' file not found

include

     ^~~~~~~

1 error generated. make: *** [devSVG.o] Error 1 ERROR: compilation failed for package ‘svglite’

hrbrmstr commented 3 years ago

Try running:

brew install libpng

at a Terminal prompt and recompiling.

brainprint commented 3 years ago

Perfect. Thank you very much.

ddauber commented 3 years ago

I had the same issue and followed the instructions. It works now. Thanks, @hrbrmstr!

joelfishbein commented 3 years ago

At first I got this error: bash: brew: command not found

I installed Homebrew (https://brew.sh/), then called brew install libpng, and then was able to install svglite as expected.

cattapre commented 3 years ago

Did not work for me. Getting the same error message

hrbrmstr commented 3 years ago

you're missing libpng in your link path somewhere. this works for everyone who has a proper homebrew or macports setup and the png library installed. these are table stakes for doing dev-based installs.

danmackinlay commented 3 years ago

Me neither @cattapre. I wonder if you, like me, have homebrew installed in a non-standard location?

danmackinlay commented 3 years ago

Also @cattapre I find that the problem as arisen in version 2.0.0.

So for me this fails, throwing the error you mention:

devtools::install_version("svglite", version = "2.0.0", repos = "http://cran.us.r-project.org")

But this works fine:

devtools::install_version("svglite", version = "1.2.3", repos = "http://cran.us.r-project.org")

Can you confirm?

C-Iacuaniello commented 3 years ago

Good morning, I am also trying to install svglite and have a similar error. I am on R version 3.6.1, I have libpng installed and up to date. I am getting the following error:

Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/systemfonts/libs/systemfonts.so': dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/systemfonts/libs/systemfonts.so, 6): Library not loaded: /opt/X11/lib/libfreetype.6.dylib Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/systemfonts/libs/systemfonts.so Reason: image not found Calls: ... asNamespace -> loadNamespace -> library.dynam -> dyn.load Execution halted ERROR: lazy loading failed for package ‘svglite’

cattapre commented 3 years ago

Also @cattapre I find that the problem as arisen in version 2.0.0.

So for me this fails, throwing the error you mention:

devtools::install_version("svglite", version = "2.0.0", repos = "http://cran.us.r-project.org")

But this works fine:

devtools::install_version("svglite", version = "1.2.3", repos = "http://cran.us.r-project.org")

Can you confirm?

My issue is gone. The binary provided fixed the problem.

shearerpmm commented 3 years ago

I also have this problem. Like @danmackinlay, I too have homebrew installed in a nonstandard location ($HOME/homebrew; this is required by my organization). We are also required to install R via homebrew, which prevents most R binaries from working (they can't find shared libraries where they expect) and forces us to compile from source in most cases.

I can see that png.h is on my computer at homebrew/Cellar/libpng/1.6.37/include/libpng16/png.h. But I don't know the magic words to get the svglite package install process to find png.h in this location.

imanuelcostigan commented 2 years ago

I too have this issue. Have brew config per default, but running on an Apple Silicon Mac.

thomasp85 commented 2 years ago

brew behaves differently on silicon and you'll need to alert R to the different location of its libraries

put this in your global .Makevars

CFLAGS=-I/opt/homebrew/include
CPPFLAGS=-I/opt/homebrew/include
CXXFLAGS=-I/opt/homebrew/include
CXX11FLAGS=-I/opt/homebrew/include
LDFLAGS=-L/opt/homebrew/lib
rohilsaraf97 commented 2 years ago

Could you please tell me where to find the global .Makevars file on macOS?

imanuelcostigan commented 2 years ago

See https://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#Installation-of-source-packages

RuDevelooper commented 2 years ago

Try running:

brew install libpng

Thank you!