summaryrefslogtreecommitdiff
path: root/gutils
diff options
context:
space:
mode:
authorpfaedit <pfaedit>2010-07-19 19:10:00 +0000
committerpfaedit <pfaedit>2010-07-19 19:10:00 +0000
commitc8eb12794824acc9ca61bc2d3234430790657fdb (patch)
tree0f0f033d3eee91bf46676cc7d3dd2d9aa9e27929 /gutils
parentdd9d21cc87345018a34c4da2534b0cf81d1ee781 (diff)
Code to pick the png shared image that matches the include file we were compiled with.
Diffstat (limited to 'gutils')
-rw-r--r--gutils/gimagereadpng.c12
-rw-r--r--gutils/gimagewritepng.c12
2 files changed, 16 insertions, 8 deletions
diff --git a/gutils/gimagereadpng.c b/gutils/gimagereadpng.c
index 7c42189e..9037d634 100644
--- a/gutils/gimagereadpng.c
+++ b/gutils/gimagereadpng.c
@@ -77,17 +77,21 @@ static int loadpng() {
return( 0 );
}
-# if !defined(_LIBPNG12)
+# if !defined(PNG_LIBPNG_VER_SONUM) || PNG_LIBPNG_VER_SONUM<10
+/* Early versions are called libpng. Later libpng10/libpng12/libpng14... */
libpng = dlopen("libpng" SO_EXT,RTLD_LAZY);
# ifdef SO_2_EXT
if ( libpng==NULL )
libpng = dlopen("libpng" SO_2_EXT,RTLD_LAZY);
# endif
-# else /* After version 1.2.1 (I think) dynamic libpng is called libpng12 */
- libpng = dlopen("libpng12" SO_EXT,RTLD_LAZY);
+# else /* After version 1.2.1 (I think) dynamic libpng is called libpng12/libpng14... */
+# define xstr(s) str(s)
+# define str(s) #s
+# define PNGLIBNAME "libpng" xstr(PNG_LIBPNG_VER_SONUM)
+ libpng = dlopen(PNGLIBNAME SO_EXT,RTLD_LAZY);
# ifdef SO_0_EXT
if ( libpng==NULL )
- libpng = dlopen("libpng12" SO_0_EXT,RTLD_LAZY);
+ libpng = dlopen(PNGLIBNAME SO_0_EXT,RTLD_LAZY);
# endif
# endif
if ( libpng==NULL ) {
diff --git a/gutils/gimagewritepng.c b/gutils/gimagewritepng.c
index b727889d..6908a1fc 100644
--- a/gutils/gimagewritepng.c
+++ b/gutils/gimagewritepng.c
@@ -65,17 +65,21 @@ static int loadpng() {
fprintf(stderr,"%s\n", dlerror());
return( 0 );
}
-# if !defined(_LIBPNG12)
+# if !defined(PNG_LIBPNG_VER_SONUM) || PNG_LIBPNG_VER_SONUM<10
+/* Early versions are called libpng. Later libpng10/libpng12/libpng14... */
libpng = dlopen("libpng" SO_EXT,RTLD_LAZY);
# ifdef SO_2_EXT
if ( libpng==NULL )
libpng = dlopen("libpng" SO_2_EXT,RTLD_LAZY);
# endif
-# else /* After version 1.2.1 (I think) dynamic libpng is called libpng12 */
- libpng = dlopen("libpng12" SO_EXT,RTLD_LAZY);
+# else /* After version 1.2.1 (I think) dynamic libpng is called libpng12/libpng14... */
+# define xstr(s) str(s)
+# define str(s) #s
+# define PNGLIBNAME "libpng" xstr(PNG_LIBPNG_VER_SONUM)
+ libpng = dlopen(PNGLIBNAME SO_EXT,RTLD_LAZY);
# ifdef SO_0_EXT
if ( libpng==NULL )
- libpng = dlopen("libpng12" SO_0_EXT,RTLD_LAZY);
+ libpng = dlopen(PNGLIBNAME SO_0_EXT,RTLD_LAZY);
# endif
# endif
if ( libpng==NULL ) {