December 29, 2009

PHP 5.3 Compile Error: Undefined Symbols in iconv

Problem

When I tried to exactly replicate my production environment on my MacBook recently, compilation failed with the following message.

Undefined symbols:
"_iconv_close", referenced from:
_do_convert in gdkanji.o
_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", referenced from:
_do_convert in gdkanji.o
"_iconv_open", referenced from:
_do_convert in gdkanji.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
_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

Solution

Add "--with-iconv=<iconv base dir>" to your configure line, replacing <iconv base dir> with the path of the root of the install location of iconv on your system (e.g. "/opt/local").

December 06, 2009

Cleaning-Up After MacPorts

Preamble

I'm a bit short on time at the moment, so over the next couple of weeks I'll be making some very brief posts. They'll mostly be just notes I've made at one time or another, but they should still be useful in some way. On with the show then...

The Problem

MacPorts is brilliant, but left to its own devices, it behaves like a lazy teenager; not tidying-up its room and leaving dirty washing lying around your hard-drive.

The problem is that downloads and build-files tend to linger, and old versions of packages are not automatically removed after being upgraded.

Cleaning-Up The Mess

Execute the following (self-explanatory) commands to clean-up MacPorts at any time.

sudo port -f clean --all installed
sudo port -f uninstall inactive


I freed-up over a gig the first time I ran these commands!

Laying Down The Law

To upgrade your installed Ports - including dependencies - and remove the outdated versions, all at the same time, execute the following commands. (For a complete solution, I've included the command to update MacPorts itself.)

sudo port selfupdate
sudo port -fuc upgrade outdated


-f = force upgrade
-u = uninstall inactive ports when upgrading and uninstalling
-c = auto-clean after install

November 21, 2009

PHP 5.3 Compile Error: Undefined References in dns.c

Problem

Compilation fails with an error like the following.

ext/standard/dns.o: In function `php_parserr':
/home/danbettles/build/php-5.3.1/ext/standard/dns.c:418: undefined reference to `__dn_expand'
/home/danbettles/build/php-5.3.1/ext/standard/dns.c:468: undefined reference to `__dn_expand'
/home/danbettles/build/php-5.3.1/ext/standard/dns.c:652: undefined reference to `__dn_expand'
/home/danbettles/build/php-5.3.1/ext/standard/dns.c:674: undefined reference to `__dn_expand'
/home/danbettles/build/php-5.3.1/ext/standard/dns.c:513: undefined reference to `__dn_expand'
ext/standard/dns.o:/home/danbettles/build/php-5.3.1/ext/standard/dns.c:519: more undefined references to `__dn_expand' follow
ext/standard/dns.o: In function `zif_dns_check_record':
/home/danbettles/build/php-5.3.1/ext/standard/dns.c:393: undefined reference to `__res_nsearch'
ext/standard/dns.o: In function `zif_dns_get_mx':
/home/danbettles/build/php-5.3.1/ext/standard/dns.c:933: undefined reference to `__res_nsearch'
/home/danbettles/build/php-5.3.1/ext/standard/dns.c:944: undefined reference to `__dn_skipname'
/home/danbettles/build/php-5.3.1/ext/standard/dns.c:951: undefined reference to `__dn_skipname'
/home/danbettles/build/php-5.3.1/ext/standard/dns.c:964: undefined reference to `__dn_expand'
ext/standard/dns.o: In function `zif_dns_get_record':
/home/danbettles/build/php-5.3.1/ext/standard/dns.c:810: undefined reference to `__res_nsearch'
/home/danbettles/build/php-5.3.1/ext/standard/dns.c:833: undefined reference to `__dn_skipname'
collect2: ld returned 1 exit status
make: *** [sapi/cgi/php-cgi] Error 1

Solution

Execute the following command before running configure.

export EXTRA_LIBS="-lresolv"

That fixed the problem on Debian. Hopefully it'll do the trick for you, too.

November 18, 2009

Dreamhost's Shared Hosting Offers PHP 5.3

UPDATE: My improved script for a minimal PHP 5.3.x install with mysqlnd and APC is now available on Dreamhost's wiki.

Sort Of

With shell access to the server, you're free to compile your own copy of PHP. Then, with a couple of lines in an .htaccess file under your site's root, you can be up and running with the latest - and greatest - version of PHP.

The only caveat: Dreamhost will not provide technical support if you go down this route. (That's unlikely to concern you, however, if you're willing to build your own copy of PHP.)

Whilst this may not be the most optimal arrangement, it's great if you can't afford - or don't really need - a VPS, and just want something to tide you over until other hosts adopt PHP 5.3 - and there's choice in the marketplace.

It's been only a few days since I started setting-up my web space, so I'm not in any position to comment on performance and the like. For what Dreamhost are charging, though, I reckon you'd be hard-pressed to complain.

Compiling PHP 5.3

There are basic instructions and an install script for PHP 5.3 on Dreamhost's wiki.

In the interests of saving time, I started-out using their script. PHP failed to build on the first run-through, however, so I've just started stripping-down the script and altering it for my own purposes. When I'm done, I'll post the script and instructions on the wiki for reference.

November 07, 2009

Doctrine API Documentation Search Plugin for Firefox

I eventually got fed-up of having to navigate over to the Doctrine site every time I wanted to view a class' documentation, so I created a very simple Firefox search plugin to make things easier.

The Doctrine API documentation doesn't have a proper search so the plugin simply takes advantage of their URL naming conventions. The plugin is fundamentally limited, therefore, allowing you to search only by class name, but that's as much as I need.

You can download it from the Firefox Add-ons site, or, if you navigate over to www.doctrine-project.org, your Firefox search box should light-up and a download link appear at the bottom of the drop-down.