libpng
libpng copied to clipboard
error: incomplete definition of type 'struct png_struct_def'
I'm using the source cloned from github, running latest version I'm guessing this is a compatibility issue?
variable has incomplete type 'png_info' (aka 'struct png_info_def') png_info info_ptr; ^ ./png.h:484:16: note: forward declaration of 'struct png_info_def'
error: incomplete definition of type 'struct png_struct_def' ./png.h:470:16: note: forward declaration of 'struct png_struct_def' typedef struct png_struct_def png_struct;
how can i fix this?
You may be running with a different libpng (probably libpng12) than the on you just built.
how can i fix that, also tried to install from here http://mac-dev-env.patrickbougie.com/libpng/ instead of github.
how can i look for the old version and remove it?
@glennrp rgb_image.cc:198:20: error: invalid use of incomplete type ‘png_info
Is there any plan to fix this error for libpng >= 15?
I have the same issue.
scanfile.c:389:41: error: dereferencing pointer to incomplete type ‘png_struct {aka struct png_struct_def}’
There is still no way to fix it?
Ok, understood. Since libpng-1.5.0, direct access to these structs is not allowed. So, I have change the other code.
So, after some investigation, I could not figure out, how to fix the code. So I did it like most of the code I saw did it and just still used png_structp
and copied the missing private header files pngpriv.h
and pngstruct.h
.
Even example.c
and pngtest.c
are using png_structp
From Readme
For a detailed description on using libpng, read libpng-manual.txt. For examples of libpng in a program, see example.c and pngtest.c.
You should have used accessor functions starting with png_get_, like png_get_rowbytes() or png_get_image_width(). Using structure definitions from copied header files may lead to errors as definitions in the headers and the ones used in the library itself may be different.
@ctruta the original bug reporters where using code built on the API for libpng 1.2 and tried to compile it against a version of libpng where the png_struct and png_info objects had been made opaque (as Glenn observed). @szymor's analysis is also correct.
@baptistapedro, @lan2720, @cgringmuth you need to understand the differences that result from major version changes of an API: your code needs to change to match the API change. @cgringmuth; you can't do that, your code will crash in the future. You need to understand that computer code has a defined API and that it can, and will, change.
It is also important to understand when developing code that help on making that code work is to be found in the documentation and such online groups as exist. Documentation gets out of date (if you were reading Greg's book it is out of date). github "Issues" are for bugs that can be demonstrated in the software where the bug is reported; if your code does not compile that's a bug in your code.