0

I'm failing to compile libpng16 out of source on OS X Mavericks. It compiled just fine before I moved upgraded to Mavericks.

I am compiling using CMake out-of-source i.e:

>cd lpng166
>mkdir build && cd build
>cmake .. && make

Which runs with no errors

Cmake generates a file pnglibconf.h which is then included using include_directories(${CMAKE_CURRENT_BINARY_DIR}) in libpngs CMakeLists.txt file.

This apparently does not work, and i get the erroneous output below.

[  3%] Building C object CMakeFiles/png16.dir/png.o
In file included from /Users/xxx/Downloads/lpng166/png.c:14:
In file included from /Users/xxx/Downloads/lpng166/pngpriv.h:237:
/Users/xxx/Downloads/lpng166/png.h:917:5: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
    png_unknown_chunkp));
    ^~~~~~~~~~~~~~~~~~
/Users/xxx/Downloads/lpng166/pngconf.h:341:70: note: expanded from macro 'PNG_CALLBACK'
#  define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
                                                                     ^
/Users/xxx/Downloads/lpng166/pngconf.h:116:27: note: expanded from macro 'PNGARG'
#  define PNGARG(arglist) arglist
                          ^
In file included from /Users/xxx/Downloads/lpng166/png.c:14:
In file included from /Users/xxx/Downloads/lpng166/pngpriv.h:761:
/Users/xxx/Downloads/lpng166/pngstruct.h:456:4: error: unknown type name 'png_unknown_chunk'
   png_unknown_chunk unknown_chunk;
   ^
In file included from /Users/xxx/Downloads/lpng166/png.c:14:
/Users/xxx/Downloads/lpng166/pngpriv.h:993:11: error: unknown type name 'png_xy'
    const png_xy *xy), PNG_EMPTY);
          ^
/Users/xxx/Downloads/lpng166/pngpriv.h:206:39: note: expanded from macro 'PNG_INTERNAL_FUNCTION'
      extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
                                      ^
/Users/xxx/Downloads/lpng166/pngconf.h:309:75: note: expanded from macro 'PNG_FUNCTION'
#  define PNG_FUNCTION(type, name, args, attributes) attributes type name args
                                                                          ^
/Users/xxx/Downloads/lpng166/png.c:3698:11: warning: implicit declaration of function 'png_gamma_significant' is invalid in C99 [-Wimplicit-function-declaration]
      if (png_gamma_significant(gamma_val))
          ^
/Users/xxx/Downloads/lpng166/png.c:3905:64: error: no member named 'colorspace' in 'struct png_struct_def'
         png_ptr->screen_gamma > 0 ?  png_reciprocal2(png_ptr->colorspace.gamma,
                                                      ~~~~~~~  ^
/Users/xxx/Downloads/lpng166/png.c:3914:13: warning: implicit declaration of function 'png_reciprocal' is invalid in C99 [-Wimplicit-function-declaration]
            png_reciprocal(png_ptr->colorspace.gamma));
            ^
/Users/xxx/Downloads/lpng166/png.c:3914:37: error: no member named 'colorspace' in 'struct png_struct_def'
            png_reciprocal(png_ptr->colorspace.gamma));
                           ~~~~~~~  ^
/Users/xxx/Downloads/lpng166/png.c:3918:22: error: no member named 'colorspace' in 'struct png_struct_def'
            png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
            ~~~~~~~  ^
/Users/xxx/Downloads/lpng166/png.c:3987:60: error: no member named 'colorspace' in 'struct png_struct_def'
         png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma,
                                                  ~~~~~~~  ^
/Users/xxx/Downloads/lpng166/png.c:3993:63: error: no member named 'colorspace' in 'struct png_struct_def'
         png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma,
                                                     ~~~~~~~  ^
/Users/xxx/Downloads/lpng166/png.c:4003:37: error: no member named 'colorspace' in 'struct png_struct_def'
            png_reciprocal(png_ptr->colorspace.gamma));
                           ~~~~~~~  ^
/Users/xxx/Downloads/lpng166/png.c:4011:22: error: no member named 'colorspace' in 'struct png_struct_def'
            png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
            ~~~~~~~  ^
3 warnings and 9 errors generated.
make[2]: *** [CMakeFiles/png16.dir/png.o] Error 1
make[1]: *** [CMakeFiles/png16.dir/all] Error 2
make: *** [all] Error 2

The build works perfectly fine if I manually copy the generated pnglibconf.h into the source directory. This has made me come to the assumption that include_directories(${CMAKE_CURRENT_BINARY_DIR}) does not work as it is supposed to.

I have tried to list the include directories using like this answer proposes. The output shows that the directory is actually in the include directories for the source. This is really confusing.

>cmake ..
-- dir='/opt/local/include'
-- dir='/Users/xxx/Downloads/lpng166/build'
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/xxx/Downloads/lpng166/build

I am using CMake version 2.8.12, and the same issue is was with 2.8.10.

Edit: Changed topic as I have discovered the main issue.

Community
  • 1
  • 1
Tor
  • 46
  • 3

0 Answers0