環境: Mac OS X Snow Leopard
libpng は /usr/X11/lib に入ってた。ヘッダファイルは /usr/X11/include にある。
$ ls -la /usr/X11/include/ | grep png
drwxr-xr-x 4 root wheel 136 6 30 11:21 libpng12
lrwxr-xr-x 1 root wheel 14 6 30 11:20 png.h -> libpng12/png.h
lrwxr-xr-x 1 root wheel 18 6 30 11:20 pngconf.h -> libpng12/pngconf.h
#define された PNG_LIBPNG_VER_STRING を出力することでバージョン番号がわかる。
C++によるバージョン番号を出力するサンプルコード。
$ cat ./libpngver.cpp
#include <png.h>
#include <iostream>
int main(void){
std::cout << PNG_LIBPNG_VER_STRING << std::endl;
}
コンパイル。
$ g++ -I/usr/X11/include -L/usr/X11/lib -lpng ./libpngver.cpp
実行結果。
$ ./a.out
1.2.41
ちなみに、環境。
$ uname -mrsv
Darwin 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
$ g++ --version
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Ref. libpng Home Page
tags: c++ libpng mac_os_x
Posted by NI-Lab. (@nilab)