I'm working on a C++ project that needs two third party libraries (libfoo.so and libbar.so). My operating system is Linux.
libfoo.so is dynamically linked to libpng14.so.14 (1.4.8) (EDIT 1)
libbar.so seems to be statically linked to an unknwon version of libpng libpng 1.2.8 (EDIT 1)
I say "seems to be" because:
ldd libbar.so
doesn't show nothing about pngnm -D libbar.so | grep png_read_png
says "004f41b0 T png_read_png"less libbar.so | grep png_read_png
says "4577: 004f41b0 738 FUNC GLOBAL DEFAULT 10 png_read_png"
When i start my program, it abort:
terminate called after throwing an instance of 'char const*'
This is gdb backtrace:
#0 0xb7ffd424 in __kernel_vsyscall ()
#1 0xb5e776a1 in raise () from /lib/libc.so.6
#2 0xb5e78de2 in abort () from /lib/libc.so.6
#3 0xb60a997f in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/gcc/i686-pc-linux-gnu/4.4.5/libstdc++.so.6
#4 0xb60a78a5 in ?? () from /usr/lib/gcc/i686-pc-linux-gnu/4.4.5/libstdc++.so.6
#5 0xb60a78e2 in std::terminate() () from /usr/lib/gcc/i686-pc-linux-gnu/4.4.5/libstdc++.so.6
#6 0xb60a7a21 in __cxa_throw () from /usr/lib/gcc/i686-pc-linux-gnu/4.4.5/libstdc++.so.6
#7 0xb5abf76d in ?? () from /usr/lib/libfreeimage.so.3
#8 0xb6fb9346 in png_error () from lib/libfsdk.so
#9 0xb6fa2a59 in png_create_read_struct_2 () from lib/libfsdk.so
#10 0xb6fa2b7a in png_create_read_struct () from lib/libfsdk.so
#11 0xb5abfa44 in ?? () from /usr/lib/libfoo.so
#12 0xb5aa766b in FreeImage_LoadFromHandle () from /usr/lib/libfreeimage.so.3
#13 0xb5aa59f6 in FreeImage_LoadFromMemory () from /usr/lib/libfreeimage.so.3
#14 0xb68a94a5 in Foo::Image::load (this=0xb4eff560, input=...)
As you can see, exception is thrown in Foo::Image::load which belong to libfoo.so
Disabling the part of my code that uses libbar.so and removing linking to it, Foo::Image::load doesn't throw any exception and works fine.
So I guess it can be due to some ambiguity in symbol table. How can I fix it?
EDIT 1
png_access_version_number()
- With libbar.so linked,
png_access_version_number()
return10208
: version 1.2.8 - Without libbar.so linked,
png_access_version_number()
return10408
: version 1.4.8