undefined symbol on run

I'm creating a PHP library in C that uses libpng, everything works fine on a Mac, but on Ubuntu Trusty, I get an error when I try to load it.


This is how I compile the code
swig -php /tmp/TestSuite/Framework/ImageCompare/Extension/image_compare.i 2>&1

cc -Wall -fpic -c /tmp/TestSuite/Framework/ImageCompare/Extension/image_compare.c 2>&1

1
2
php-config --includes 2>&1
-I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib


gcc -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -fpic -c /tmp/TestSuite/Framework/ImageCompare/Extension/image_compare_wrap.c 2>&1



This is how I link it
gcc -lpng -shared *.o -o /tmp/TestSuite/Framework/ImageCompare/Extension/image_compare.so 2>&1



This is how I try to install it
1
2
php-config --extension-dir 2>&1
/usr/lib/php5/20121212


sudo cp /tmp/TestSuite/Framework/ImageCompare/Extension/image_compare.so /usr/lib/php5/20121212

1
2
php -r 'echo phpinfo();' | grep 'Loaded Configuration File'
Loaded Configuration File => /etc/php5/cli/php.ini


1
2
grep 'extension=image_compare.so' /etc/php5/cli/php.ini"
extension=image_compare.so 




This is how I first run it
1
2
php -r 'include("/tmp/TestSuite/Framework/ImageCompare/Extension/image_compare.php"); echo image_compare::image_compare_ping("Hello");'
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/image_compare.so' - /usr/lib/php5/20121212/image_compare.so: undefined symbol: png_read_update_info in Unknown on line 0



As you can see, there are no compiler or linker errors., libpng-dev was installed via apt-get. The weirdest things to me is that even though I get no errors, I don't see libpng being a dependency of my library:

1
2
3
4
ldd /usr/lib/php5/20121212/image_compare.so
	linux-vdso.so.1 =>  (0x00007fff2a9fe000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f96b1c37000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f96b220f000)
Last edited on
Topic archived. No new replies allowed.