How do I get my PECL extension compiling on Windows?

1. Does it require a library?

If your extension links to an external library, you will need at least two builds of the library, one with Visual Studio 6 (VC6) and one with Visual Studio 2008 (VC9). We prefer static libraries, so the library can be embedded in the php extension dll, and windows users don't have to mess with anything to get the extension running immediately.

There is a lot of information about libraries at Windows Library Page including some guidelines for building.

2. Does it compile with Visual C++?

First of all, any extension needs a config.w32 to compile on windows. This file looks very similiar to a config.m4 and tells the configure system HOW to build your extension. There are lots of extensions both in core and PECL with config.w32 files you can look at for help.

Secondly, you need to be careful with the code itself. VC can be a strict compiler and doesn't like things like declarations all over the place (they must be first in the block) and sometimes has different ways of doing types (long long doesn't work so well). These kind of issues are easier to find once you actually have a config.w32 and are attempting to actually compile the extension.

3. Does it work properly on Windows?

The only way to figure this out is to have good tests for your extension, so you can see if a different OS changes some of your functionality.

internals/windows/peclbuilds.txt · Last modified: 2017/09/22 13:28 by