Can't get mcrypt working for PHP 5.4.16 (multiple version of PHP)

Getting mcrypt working for PHP 5.4.16 with multiple PHP versions.

I am having awful trouble trying to compile the mcrypt extension for php 5.4.16, I even have tried using a sandbox developer machine for PHP to compile a standard install of 5.4.16 from source including the mcrypt extension but keeps throwing up errors.

The first one I get from doing it the standard way on the multiple php virtualmin machine I get the following:

/root/Downloads/php/php-5.4.16/ext/mcrypt/mcrypt.c:283: error: ‘PHP_FE_END’ undeclared here (not in a function) make: *** [mcrypt.lo] Error 1

That I have heard about is because php was compiled into a directory different to it’s usual one like /usr for example I think from what I have heard about on the web.

So being persistent as I am tried running a compiled from source with just mcrypt extension, but keeps giving me this error now:

PHP Warning: PHP Startup: mcrypt: Unable to initialize module Module compiled with module API=20090626 PHP compiled with module API=20100525 These options need to match in Unknown on line 0

I really am beyond understanding what I can do about this, is there anyway I can install mcrypt to get it working for PHP at all?

I prefer to show what I have done to sort this out (don’t like asking for help much, only to aid others most of the time on my blog) but this is really beyond me now.

Any helps massively appreciated.