我无法在 OS X Mavericks 上从源代码中编译 libpng16。在我升级到 Mavericks 之前,它编译得很好。
我正在使用CMake
源外编译,即:
>cd lpng166
>mkdir build && cd build
>cmake .. && make
哪个运行没有错误
Cmake
生成一个文件pnglibconf.h
,然后将其包含include_directories(${CMAKE_CURRENT_BINARY_DIR})
在 libpngs CMakeLists.txt 文件中。
这显然不起作用,我得到下面的错误输出。
[ 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})
不能按预期工作的假设。
我已尝试使用此答案建议的方式列出包含目录。输出显示该目录实际上位于源的包含目录中。这真的很令人困惑。
>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。
编辑:因为我发现了主要问题而改变了话题。