I am trying to compile the imagemagick (imagick) extension for use in a non-threading environment on windows.
I am using PHP 5.3.10 and have configured Visual C ++ express as my compilation environment. The problem is that I'm using a non-threaded version of PHP as the FCGI module in Apache 2.2.
This way my PHP comes with php5.lib
, not php5ts.lib
. I believe that it is for this reason that I get these errors:
imagick.obj : error LNK2019: unresolved external symbol __imp__tsrm_mutex_alloc referenced in function _zm_startup_imagick
I only ever created and compiled things on Linux, so I'm not too sure how to do this on a Windows environment.
How can I compile the extension so that it is not thread safe?
I downloaded the PHP 5.3.10 file binary to get a copy of php5ts.lib. Then I was able to compile the extension.
I assume that setting the ZTS
preprocessor directive to 1
or 0
will cause the extension to compile both thread-safe and non-stream. (Not too sure about this, so if someone can tell me if this is correct or not, that would be very appreciated. :))
Then I set up a virtual machine running Windows 7 and installed the latest version of WAMP. The reason is that he used a streaming version of PHP.
I placed the dll in the ext folder in the PHP installation and included it in php.ini
. However, even after trying to use the ts and nts version in WAMP, I would get:
PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.3.10/ext/imagick.dll' - The specified module could not be found. in Unknown on line 0
But the fact is that c:/wamp/bin/php/php5.3.10/ext/imagick.dll'
exists, and yes, I checked it many times.
Then I downgraded ImageMagick to 6.6.2-10-Q16, but still see the same problem.
The same problem occurs on my dev machine, which runs the nts version of PHP 5.3.10 on Apache 2.2 (everything is installed manually).
Looks like I was wrong about the ZTS
preprocessor. If I set ZTS=0
and compile, using the dependent walker on the compiled dll still shows that it requires php5ts.dll
, which is only present in thread safe versions of PHP.
I was more interested in finding dependencies and found that I had to statistically refer to msvc100d.dll. Then I removed ZTS
in the preprocessor definition and was able to compile using php5.lib
instead of php5ts.dll
. I think this should get me non-ts dll.
However, when I download the extension, I still get:
PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'imagick.dll' in Unknown on line 0
And errors from walking dependencies:
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module. Error: Modules with different CPU types were found. Warning: At least one delay-load dependency module was not found. Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
Installed visual C ++ express 2008 and compiled using the v90 platform toolkit, but still faces the same problems.
Any advice appreciated :)
Solution found! See my answer.