php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38868 GD extensions needs '-lm' linker flag
Submitted: 2006-09-18 16:00 UTC Modified: 2006-10-06 07:48 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (100.0%)
From: flconseil at yahoo dot fr Assigned:
Status: Wont fix Package: Compile Failure
PHP Version: 5.1.6 OS: AIX 5.2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-09-18 16:00 UTC] flconseil at yahoo dot fr
Description:
------------
Building PHP 5.1.6 on AIX 5.2. GD compiled in shared mode. gd.so is linked without the math library (-lm). Then, when loading the GD extension, we get an error for all the math functions it is using (sqrt(), ...).

Workaround: after having built everything and before install :

rm ext/gd/gd.so
gmake LDFLAGS="$LDFLAGS -lm"

and, now, it can be loaded.

Reproduce code:
---------------
./configure --with-gd=shared
and then loading gd.

Expected result:
----------------
load OK

Actual result:
--------------
I don't have the exact messages but they are all about unsesolved symbols from the math library (there is at least sqrt()).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-18 16:22 UTC] tony2001@php.net
Can't reproduce on AIX 5.1.
PHP itself is linked with libm, so it should not matter whether extension itself is linked or not.
 [2006-09-18 16:29 UTC] tony2001@php.net
make sure you're using GNU ld and GNU buildtools.
 [2006-09-18 16:43 UTC] flconseil at yahoo dot fr
Same problem with 5.1.2.

Here are the exact error messages :

PHP Warning:  dl(): Unable to load dynamic library '/logi/http/php/lib/php/extensions/gd.so' - rtld: 0712-001 Symbol sqrt was referenced
      from module /logi/http/php/lib/php/extensions/gd.so(), but a runtime definition
            of the symbol was not found.
rtld: 0712-001 Symbol atan2 was referenced
      from module /logi/http/php/lib/php/extensions/gd.so(), but a runtime definition
            of the symbol was not found.
rtld: 0712-001 Symbol sin was referenced
      from module /logi/http/php/lib/php/extensions/gd.so(), but a runtime definition
            of the symbol was not found.
rtld: 0712-001 Symbol cos was referenced
      from module /logi/http/php/lib/php/extensions/gd.so(), but a runtime definition
            of the symbol was not found.
rtld: 0712-001 Symbol tan was referenced
      from module /logi/http/php/lib/php/extensions/gd.so(), but a runtime definition
            of the symbol was not found.
rtld: 0712-001 Symbol floor was referenced
      from module /logi/http/php/lib/php/extensions/gd.so(), but a runtime definition
            o in /logi/http/comp/util/.data/test.php on line 22

Warning: dl(): Unable to load dynamic library '/logi/http/php/lib/php/extensions/gd.so' - rtld: 0712-001 Symbol sqrt was referenced
      from module /logi/http/php/lib/php/extensions/gd.so(), but a runtime definition
            of the symbol was not found.
rtld: 0712-001 Symbol atan2 was referenced
      from module /logi/http/php/lib/php/extensions/gd.so(), but a runtime definition
            of the symbol was not found.
rtld: 0712-001 Symbol sin was referenced
      from module /logi/http/php/lib/php/extensions/gd.so(), but a runtime definition
            of the symbol was not found.
rtld: 0712-001 Symbol cos was referenced
      from module /logi/http/php/lib/php/extensions/gd.so(), but a runtime definition
            of the symbol was not found.
rtld: 0712-001 Symbol tan was referenced
      from module /logi/http/php/lib/php/extensions/gd.so(), but a runtime definition
            of the symbol was not found.
rtld: 0712-001 Symbol floor was referenced
      from module /logi/http/php/lib/php/extensions/gd.so(), but a runtime definition
            o in /logi/http/comp/util/.data/test.php on line 22
 [2006-09-18 16:48 UTC] tony2001@php.net
Please read my previous comments.
 [2006-09-18 16:51 UTC] flconseil at yahoo dot fr
OK. I was using GNU make but not GNU ld. I am going to try it.
 [2006-09-18 21:05 UTC] flconseil at yahoo dot fr
Sorry but, after fighting with GNU ld and gcc during 2 hours, I am giving up. Using GNU ld brings some new errors in the configure stage. I solved one by adding '-Wl,-rpath,/usr/lib' to LDFLAGS but, now, it is failing LDAP detection and I won't spend the night on it. Another reason why I am giving up is that ldap's configure refuses to generate dynamic libraries with GNU ld (saying that GNU ld is known not to generate correct dynamic libs on AIX). So, as I want to generate everything with the same linker, I will keep the AIX linker.

But I think I know why we have unresolved references when loading gd. As you said, the PHP core is linked with GNU ld but, on AIX, if the linker does not detect any reference to a library, it does not keep it in the list of required libraries. In my configuration, as I have kept the core to the minimum, I don't have any reference from the core to libm and, when I run 'ldd' or 'dump -H' against 'php' or 'libphp5.so', the libm is not referenced.

As, by default, gd is not linked with the libm, it does not have the reference and, finally, when it is loaded, the libm symbols cannot be resolved as this lib is not referenced anywhere in the installed files.

That's why, as every other extension is linked against the libs it needs, I still think that gd should be linked explicitely with the libm.
 [2006-09-18 21:17 UTC] tony2001@php.net
Sorry, we do not support AIX native linker.

 [2006-10-06 07:48 UTC] flconseil at yahoo dot fr
Sorry to insist but I wanted to make it clear because I reference it in my (excellent :-) document about building PHP on AIX (http://www.tekwire.net/joomla/content/view/16/1/), and several people asked about this bug's status.

While I generally agree with your decision of restricting the build environment you support, I must say that it is not the case for GNU ld. It is perfectly legitmate not to support native compilers but linkers are a more sensitive case and attempting to use only the GNU linker on systems like AIX or HP-UX has a number of side effects impossible to solve for non-expert people. Building Apache & PHP on these systems is already complex (especially PHP 4) and it is not worth the pain to add another difficulty to the task. For people used to their OS, using gcc is not a problem, but using the GNU linker is not natural and the switch is much less transparent.

And there is still this message when compiling LDAP saying that it refuses to generate dynamic libs because GNU ld is supposed not to generate them properly on AIX. Do you consider it as a wrong assertion in LDAP's configure ? What's your advice about this ?

Francois
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Jan 17 04:01:24 2019 UTC