Re: [INTERNALS-WIN] Developing PHP extensions on Windows with VC++, linking problems

[email protected] (Kalle Sommer Nielsen)
Newsgroups php.internals.win
Message-ID <[email protected]>
Hi

2009/5/11 Eugenio Tacchini <[email protected]>:
> At 08.26 11/05/2009 +0200, Kalle Sommer Nielsen wrote:
>>
>>Thats because your header file does not define the module pointer,
>>checkout any extension and you should see something like:
>>
>>extern zend_module_entry <myext>_module_entry;
>>#define phpext_<myext>_ptr &<myext>_module_entry
>
> Hello Kalle,
> thanks for your reply.
> My header file, stdafx.h, just contains these lines:

This is defined in the php_<myext>.h file, so your php_<myext>.h file
may looks like:

#ifndef HAVE_MYEXT_H
#define HAVE_MYEXT_H

extern zend_module_entry myext_module_entry;
#define phpext_myext_ptr &myext_module_entry;

#endif

And in your main c file:

#include "php.h"
#include "php_myext.h"

#ifdef COMPILE_DL_MYEXT
ZEND_GET_MODULE(myext)
#endif

/* arginfo, zend_function_entry, zend_module_entry etc. */

/* extension implementation */


As for your config.w32, you should use ARG_[WITH|ENABLE] to add the
ability to enable and disable the extension, especially if your
planning to publish it somewhere. Example:

/* --enable-myext (shows MyExt support on configure --help), and
defaults to not enabled */
/* enable is used for extensions that does not require any external
libraries, with is used otherwise, e.g. gd */
ARG_ENABLE('myext', 'MyExt support', 'no');

/* ARG_ENABLE creates PHP_MYEXT and PHP_MYEXT_SHARED (both uppercase) */
/* PHP_MYEXT is the value of --enable-myext=X, and 'yes', depending on
the default if no arg set */
/* PHP_MYEXT_SHARED is a boolean */
if(PHP_MYEXT != 'no')
{
	EXTENSION('myext', 'myext.c someotherfile.c et.c');
}

You don't need to include zend_config.w32.h, php.h gets the
config.w32.h files already (from main/ and Zend/)

>
> #pragma once
>
> // Include the Zend Win32 header and the general PHP header
> #include "zend_config.w32.h"
> #include "php.h"
>
> so, the only thing I have to do is to add
> extern zend_module_entry my_extension_module_entry;
> #define phpext_my_extension_ptr &my_extension_module_entry
>
> at the end of the file?
>
> Thanks.
>
> Eugenio
>
>
> --
> Windows Internals Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Kalle Sommer Nielsen
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.