Re: php extensions on windows
| From: | J Smith | Date: | Thu, 18 Apr 2002 18:45:27 +0000 |
| Subject: | Re: php extensions on windows | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-82975@lists.php.net to get a copy of this message | ||
I've been working on this sort of thing for the past few weeks as I've been
trying to make sure all of the PHP extensions I've written work on UNIX
systems as well as Windows systems.
I think you can compile using gcc and cygwin, but I believe the recommended
way is with Visual C++ 6, as the official binaries are done with VC++. (I
think, I don't use PHP in Windows except to test portability.)
Anyways, here's what I do as far as settings. This is for a thread-safe
release extension. I'm assuming you have a bit of experience working with
VC++ and the PHP source, and that you're able to compile PHP in the first
place.
0. Start a new project in VC++ and add your extension's files.
1. In the Configurations dialog, add two configurations: Release_TS and
Debug_TS. Release_TS should copy the settings from Release and Debug_TS
should obviously copy from Debug. You can Remove Release and Debug and
close the dialog. The next set of steps is for the Release_TS
configuration. If you can figure that out, you should be able to get
Debug_TS working fine.
2. Open up Project->Settings. On the C/C++ tab, General Category, added the
following preprocessor definitions: ZEND_DEBUG=0,
COMPILE_DL_YOUR_EXTENSION_NAME, ZTS=1, ZEND_WIN32, PHP_WIN32.
YOUR_EXTENSION_NAME is the name you'll find in the sources generated by
ext_skel.
3. In the Code Generation Category, change Use run-time Library to
"Multithreaded DLL".
4. In the Preprocessor Category, add the following "Additional include
directories": ..\.., ..\..\main, ..\..\Zend, ..\..\TSRM, ..\..\bindlib_w32.
5. On the Link tab in the General Category, change the Output file name to
..\..\Release_TS/php_yourextension.dll.
6. On that same tab, same category, add php4ts.lib to Object/library
modules.
7. In the Input Category, add the following to Additional library path:
..\..\Release_TS.
That should be it. Close dialog and set the active configuration to
Release_TS and (hopefully) build the DLL.
If you're using other libraries and such, make sure you compile them using
the multithreaded DLL runtime library like you did with your extension. I
found that out the hard way trying to get my cryptopp extension working on
Windows.
Check out some of the VC++ project files included with the PHP source when
you're stuck and try to replicate the settings they use in your own
project. It takes a while to get used to building extensions with VC++
'cause that sort of thing is so poorly documented in the Windows world, but
once you get it once you should be fine.
J
Igal Raizman wrote:
> Hello,
>
> Can someone point me in the directions of a tutorial or perhaps some info
> on making PHP extensions on a Windows system ?
>
> not on how to code them, but rather on how to compile them on a windows
> system.
>
> Thanks,