xucheng/android-sdk

android-utils-4.4-r1 - aapt/Images.cpp would not compile against libpng>1.4

GoogleCodeExporter opened this issue · 0 comments

g++ -DPACKAGE_NAME=\"android-utils\" -DPACKAGE_TARNAME=\"android-utils\" 
-DPACKAGE_VERSION=\"4.4\" -DPACKAGE_STRING=\"android-utils\ 4.4\" 
-DPACKAGE_BUGREPORT=\"cjacker@gmail.com\" -DPACKAGE_URL=\"\" -DYYTEXT_POINTER=1 
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STDDEF_H=1 -DHAVE_STDINT_H=1 
-DHAVE_STDLIB_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_UNISTD_H=1 
-DHAVE_CHOWN=1 -DHAVE_FORK=1 -DHAVE_VFORK=1 -DHAVE_WORKING_VFORK=1 
-DHAVE_WORKING_FORK=1 -DHAVE_MEMSET=1 -DHAVE_STRDUP=1 -DHAVE_STRRCHR=1 
-DHAVE_STRTOUL=1 -I.    -I../aapt/include -I../libcutils/include 
-I../libutils/include -I../libhost/include -DHAVE_SYS_UIO_H -DHAVE_PTHREADS 
-DHAVE_SCHED_H -DHAVE_SYS_UIO_H -DHAVE_IOCTL -DHAVE_TM_GMTOFF -DANDROID_SMP=1 
-DHAVE_ENDIAN_H -DHAVE_POSIX_FILEMAP -DHAVE_OFF64_T -Wno-format-y2k 
-DHAVE_ENDIAN_H -DHAVE_SCHED_H -DHAVE_EXPAT_CONFIG_H -g -O2 -MT aapt-Images.o 
-MD -MP -MF .deps/aapt-Images.Tpo -c -o aapt-Images.o `test -f 'Images.cpp' || 
echo './'`Images.cpp
Images.cpp: In function ‘void png_write_aapt_file(png_structp, png_bytep, 
png_size_t)’:
Images.cpp:21:39: error: invalid use of incomplete type ‘png_struct {aka 
struct png_struct_def}’
     status_t err = ((AaptFile*)png_ptr->io_ptr)->writeData(data, length);
                                       ^
In file included from Images.cpp:14:0:
/usr/include/png.h:576:16: error: forward declaration of ‘png_struct {aka 
struct png_struct_def}’
 typedef struct png_struct_def png_struct;
                ^
Images.cpp: In function ‘void read_png(const char*, png_structp, png_infop, 
image_info*)’:
Images.cpp:93:41: error: ‘png_set_gray_1_2_4_to_8’ was not declared in this 
scope
         png_set_gray_1_2_4_to_8(read_ptr);
                                         ^
Images.cpp:112:52: error: expected primary-expression before ‘)’ token
         outImageInfo->height * png_sizeof(png_bytep));
                                                    ^
Images.cpp:112:52: error: ‘png_sizeof’ was not declared in this scope
Images.cpp: In function ‘android::status_t do_9patch(const char*, 
image_info*)’:
Images.cpp:576:66: error: expected primary-expression before ‘)’ token
     image->rows = (png_bytepp)malloc((H-2) * png_sizeof(png_bytep));
                                                                  ^
Images.cpp:576:66: error: ‘png_sizeof’ was not declared in this scope
Images.cpp: In function ‘void write_png(const char*, png_structp, png_infop, 
image_info&, int)’:
Images.cpp:987:91: error: expected primary-expression before ‘)’ token
     png_bytepp outRows = (png_bytepp) malloc((int) imageInfo.height * png_sizeof(png_bytep));
                                                                                           ^
Images.cpp:987:91: error: ‘png_sizeof’ was not declared in this scope
Images.cpp:1000:42: error: ‘Z_BEST_COMPRESSION’ was not declared in this 
scope
     png_set_compression_level(write_ptr, Z_BEST_COMPRESSION);
                                          ^
Makefile:574: recipe for target 'aapt-Images.o' failed


Notice here http://www.libpng.org/pub/png/libpng.html says:

The libpng 1.5.x and 1.6.x series continue the evolution of the libpng API, 
finally hiding the contents of the venerable and hoary png_struct and png_info 
data structures inside private (i.e., non-installed) header files. Instead of 
direct struct-access, applications should be using the various png_get_xxx() 
and png_set_xxx() accessor functions, which have existed for almost as long as 
libpng itself.

Probably you need to update the source code. There seemed to be be a lot of 
changes in current 
https://github.com/android/platform_frameworks_base/blob/master/tools/aapt/Image
s.cpp

Original issue reported on code.google.com by ihatewin...@gmail.com on 23 May 2014 at 10:55