我无法在OS X Mavericks上编译libpng16。 在我升级到Mavericks之前,它编译得很好。
我正在使用CMake
来源编译:
>cd lpng166
>mkdir build && cd build
>cmake .. && make
哪个运行没有错误
Cmake
生成一个文件pnglibconf.h
,然后在libpngs CMakeLists.txt文件中使用include_directories(${CMAKE_CURRENT_BINARY_DIR})
包含该文件。
这显然不起作用,我得到下面的错误输出。
[ 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
如果我手动将生成的pnglibconf.h
复制到源目录中,则构建工作完全正常。这使我开始假设include_directories(${CMAKE_CURRENT_BINARY_DIR})
不能正常工作。
我尝试使用类似this answer建议列出包含目录。输出显示该目录实际上位于源的include目录中。这真令人困惑。
>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
我正在使用CMake版本2.8.12,同样的问题是2.8.10。
编辑: 由于我发现了主要问题,因此更改了主题。