Stop Microsoft

Miscellaneous => Technical Support => Topic started by: worker201 on 24 January 2010, 14:33

Title: PHP build chokes
Post by: worker201 on 24 January 2010, 14:33
Of course OSX has php built-in.  But of course it isn't built with postgresql support, which I need for a project.  So I'm trying to build my own version and failing.  Here are some of the lurid details.

PHP version - 5.3.1

Configure:
Code: [Select]
./configure --prefix=/usr/local/php5 --with-libxml-dir=/opt/local
--enable-exif --with-openssl=/opt/local --with-zlib --with-zlib-dir=/opt/local
--with-bz2=/opt/local --with-curl=/opt/local --with-jpeg-dir=/opt/local
--with-png-dir=/opt/local --with-freetype-dir=/opt/local --with-openssl-dir=/opt/local
--with-gettext=/opt/local --with-mysql=/usr/local/mysql --with-pgsql=/Library/PostgreSQL/8.4/bin
--enable-soap --with-xsl=/opt/local --enable-shared --enable-static --with-iconv-dir=/usr/local/libiconv
Most of the stuff needed was installed with MacPorts, which keeps everything in /opt/local.  Originally, libiconv was there also, but I thought it might be the problem, so I built my own version from source.

The relevant part of the make process:
Code: [Select]
Undefined symbols:
  "_iconv_close", referenced from:
      _php_iconv_string in iconv.o
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      __php_iconv_strpos in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_substr in iconv.o
      _php_iconv_stream_filter_dtor in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
  "_iconv_open", referenced from:
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      __php_iconv_strpos in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _php_iconv_stream_filter_factory_create in iconv.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [sapi/cgi/php-cgi] Error 1

Supposedly, I can build --without-iconv.  Would that be wise?  Any other suggestions?
Title: Re: PHP build chokes
Post by: worker201 on 25 January 2010, 01:08
Thanks for all your help, guys.  As it turns out, this is a known bug in the libiconv included in Leopard.  The workaround is to use --with-iconv=shared,[dir] instead of --with-iconv-dir=[dir].  This has something to do with bypassing the search path and forcing the linker to skip over the built-in libiconv in favor of the aftermarket version.  I was able to build successfully using the libiconv from MacPorts, so I can go ahead and remove that GNU source version I built.
Title: Re: PHP build chokes
Post by: worker201 on 25 January 2010, 02:37
Oops, I forgot something:
--with-apxs2=/usr/sbin/apxs

Yes, I'm talking to myself.  But maybe this will help someone, eventually.
Title: Re: PHP build chokes
Post by: Aloone_Jonez on 25 January 2010, 03:38
Lol, I did read this thread.

All I have to say is that I have no clue as I don't know any PHP but I thought I'd respond in the hope it'll make you feel better as it is frustrating when you think no one's listening. :)
Title: Re: PHP build chokes
Post by: piratePenguin on 25 January 2010, 08:09
How many mac os x software compiling people come on this forum every day to respond to threads? :s
Title: Re: PHP build chokes
Post by: worker201 on 25 January 2010, 11:16
Adding the apxs line to the configure changed things immensely.  Now all sorts of things are broken, including openssl and libxml2.  For starters, the Apple versions are either too far behind or corrupted in some way.  To complicate matters, the PHP makefiles will not search for the libraries you tell it to use if those libraries are found in the system folders.

An excellent discussion of why it does this, and what can be done to fix it:
http://blog.yimingliu.com/2009/02/24/missing-library-symbols-while-compiling-php-528/ (http://blog.yimingliu.com/2009/02/24/missing-library-symbols-while-compiling-php-528/)

I'm doing it the fun way, by renaming the system libraries temporarily, which will force the makefile to find the libraries in the locations I have specified.  Just hope I remember to change them back afterwards.
Title: Re: PHP build chokes
Post by: worker201 on 26 January 2010, 00:12
Finally got this thing working.  Ended up having to modify the makefile.

Proof:

(http://www.triple-bypass.net/download/screenshots/proofphp.jpg)
Title: Re: PHP build chokes
Post by: worker201 on 31 January 2010, 03:52
Okay, the PHP issue is past.  But then I was modifying the httpd-vhosts.conf file, and suddenly Apache shit all over the rug and started complaining that it couldn't find the PHP module.  So I had to start over again.  This time, I found a method that allowed me to install Apache 2.2.14 right over top of the built-in 2.0.x version.  Then I built the PHP, and verified that it was working.  But then when I went to check my phpinfo() in the browser (Firefox), it clearly wasn't working at all.  After some testing, I found the issue, and started over AGAIN.  The browser, though, stayed open, because I was working on something else (my online job).  After finally rebuilding Apache and PHP, things seemed okay, and the server restarted without issue, and the virtual hosts were working just fine, but phpinfo() still wasn't working.  Man, I wracked my brain and kicked my computer and studied for hours about mime types and verified ten times over that everything was installed right.  Then on a whim, I decided to check it in Safari.  Worked right away, no issues.  After restarting Firefox, it worked right as well.

I guess this is normal behavior - the content of the webroot folder had not changed even by a byte, so a refresh had no effect.  For future reference, how can you force the browser to renegotiate with the host so that server function changes have an effect?  Surely it's not necessary to reboot the browser everytime I make development changes?
Title: Re: PHP build chokes
Post by: davidnix71 on 31 January 2010, 05:17
Firefox ram/hd caches a lot of things. I force FF to delete everything but my passwords and bookmarks every time it quits, just to be sure.

I also can't get torrents to run from localhost (a desktop file) in Opera 10, either, but that worked in Opera 9. All it will do is try to resave the existing file.
Title: Re: PHP build chokes
Post by: piratePenguin on 1 February 2010, 14:44
Quote from: http://support.mozilla.com/en-US/forum/1/333668?s=cache%20refresh
You can bypass the cache with Ctrl+F5 (IE: Shift+F5, if I'm correct) or Shift+Ctrl+R.
Firefoxes help system (press f1) is pretty damn legendary

edit: also you can hold shift while clicking the refresh button
Title: Re: PHP build chokes
Post by: worker201 on 4 April 2010, 21:17
Fuck me skating.  After all this work to get PHP5 and Apache 2.2 and PostgreSQL running, the whole system was laid waste by installing a Leopard security update.  Now I'm back to Mac default Apache and PHP, and no PostgreSQL support.  Goddammit.