compiling php on osx snow leopard 10.6.2
conceived on 41-10-14 ∇ 16:49:54I've been compiling various recent builds of PHP on OS X 10.6.2 a lot lately and I thought it may off help to someone to share the solution to a problem I continually run into.
Everything seems to go fine up to the point of running make where it will then error out claiming Undefined symbols: "_libiconv", referenced...
Unfortunately, it's beyond my knowledge as to the what the actual problem is and/or who's fault. But, it appears, according to the many blog posts, comments and bug threads I've had to wade through that it has something to do with either having multiple iconv libraries installed on my machine, library reference artifacts from one of the core team member's build and/or php's make file parameter order. Long story longer: I'd love to deliver a clearer answer, but I just don't have time to really look deeper. I don't really care why it doesn't work or why this solution may or may not be the best -- This isn't for production purposes -- I just want it to work so I can develop on my local machine, without having to risk inadvertently breaking something else by "cleaning up" or replacing the native iconv lib(s) that come with the OS.
the solution
patching ext/iconv/iconv.c
Assuming you have the source for php 5.3.1 and it is extracted to a folder somewhere, dive into that folder and then into ext/iconv/. Next, in your favorite text editor open up the iconv.c that resides there.
Now, all you have to do is delete six lines of code. Remove lines 50,51,52 and 185,186,187. That's it for the first step.
patching your Makefile
Run ./configure --your-params as you normally would and then dive into the MakeFile in your favorite text editor. I deleted my makefile for my 5.3 build prior to writing this and don't care to recompile at this moment, so the screenshot above is from a recent 5.2.13 build - so the line number may vary but the patch is the same. Seek the line referenced and cut the $(MH_BUNDLE_FLAGS) parameter, and paste it on that same line right before the -o $@ && cp ... is referenced. Check out the second screenshot above.
You're Dunn!
Now, continue with make && sudo make install and you should be good to go. Hopefully this helps someone -- or maybe someone will shoot me a message on twitter or otherwise telling me why this is absolutely horrible and I'm a bad person for sharing. Good thing I don't have comments!