LibPNG + Boost::GIL: png_infopp_NULL not found

2020-06-23 06:51发布

I always get this error when trying to compile my file with Boost::GIL PNG IO support:

(I'm running Mac OS X Leopard and Boost 1.42, LibPNG 1.4)

/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In member function 'void boost::gil::detail::png_reader::init()':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:155: error: 'png_infopp_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:160: error: 'png_infopp_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In destructor 'boost::gil::detail::png_reader::~png_reader()':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:174: error: 'png_infopp_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In member function 'void boost::gil::detail::png_reader::apply(const View&)':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:186: error: 'int_p_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In member function 'void boost::gil::detail::png_reader_color_convert<CC>::apply(const View&)':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:228: error: 'int_p_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In member function 'void boost::gil::detail::png_writer::init()':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:317: error: 'png_infopp_NULL' was not declared in this scope

2条回答
放我归山
2楼-- · 2020-06-23 07:32

libpng 1.4 dropped definitions of png_infopp_NULL and int_p_NULL. So add

#define png_infopp_NULL (png_infopp)NULL
#define int_p_NULL (int*)NULL

in your code before including GIL headers.

查看更多
一夜七次
3楼-- · 2020-06-23 07:48

Initially I used libpng 1.4. I switched to version 1.2 and all the problems went away.

查看更多
登录 后发表回答