#13266 [Com]: Maybe not a PHP Library ?
| From: | adrian at ideasvivas dot com | Date: | Sat, 20 Sep 2003 05:53:27 +0000 |
| Subject: | #13266 [Com]: Maybe not a PHP Library ? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-47858@lists.php.net to get a copy of this message | ||
ID: 13266
Comment by: adrian at ideasvivas dot com
Reported By: atur at vigorsoft dot com
Status: Bogus
Bug Type: Dynamic loading
Operating System: Windows NT 4.0
PHP Version: 4.0.6
New Comment:
I Found this answer in this url;
www.faqts.com/knowledge_base/index.phtml/fid/68
ANSWER:
=======
You forgot to set the appropriate preprocessor flags for your C code.
If you look hard at the C code that the 'ext_skel' script makes for
you, you will see a small section that looks something like this:
#ifdef COMPILE_DL_MYMODULE
ZEND_GET_MODULE(mymodule)
#endif
If you do not set the value for 'COMPILE_DL_MYMODULE' into your
preprocessor, then php.exe will not recognize your module as
a php dll. To do this in Visual C++, go to
Project > Settings > c/c++ tab
Set Category to Preprocessor, and add COMPILE_DL_MYMODULE to the
end of your preprocessor definitions. You should probably also
leverage ZEND_WIN32 and PHP_WIN32 if you have windows specific
code that you wish to wrapper in preprocessors.
Welcome,
Bex
Previous Comments:
------------------------------------------------------------------------
[2001-09-13 02:02:24] hholzgra@php.net
once again: ask the phpdev mailing list, please
supscription information can be found
on http://php.net/support.php
------------------------------------------------------------------------
[2001-09-13 01:43:30] atur at vigorsoft dot com
Hi,
The module entry is in the source..
I am pasting header and source file for reference..
---------------------------------------------------------------------------
/* ------------------------------------------ */
/* php_mymodule.h --- after removing comments */
/* ------------------------------------------ */
#ifndef PHP_MYMODULE_H
#define PHP_MYMODULE_H
extern zend_module_entry mymodule_module_entry;
#define phpext_mymodule_ptr &mymodule_module_entry
#ifdef PHP_WIN32
#define PHP_MYMODULE_API __declspec(dllexport)
#else
#define PHP_MYMODULE_API
#endif
extern "C"
{
PHP_FUNCTION(confirm_mymodule_compiled);
}
#ifdef ZTS
#define MYMODULE_G(v) (mymodule_globals->v)
#define MYMODULE_LS_FETCH() zend_mymodule_globals *mymodule_globals =
ts_resource(mymodule_globals_id)
#else
#define MYMODULE_G(v) (mymodule_globals.v)
#define MYMODULE_LS_FETCH()
#endif
#endif /* PHP_MYMODULE_H */
/* ------------------------------------------ */
/* mymodule.cpp --- after removing comments */
/* ------------------------------------------ */
#define DHAVE_APDEBUG 1
#define DCOMPILE_DL_APDEBUG 1
#define ZTS 1
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include <iostream.h>
extern "C"
{
#include "ext/standard/info.h"
#include "php_globals.h"
#include "php_ini.h"
#include "php_mymodule.h"
}
/* True global resources - no need for thread safety here */
static int le_mymodule;
/* Every user visible function must have an entry in
mymodule_functions[]. */
function_entry mymodule_functions[] = {
PHP_FE(confirm_mymodule_compiled,NULL)
{NULL, NULL, NULL}
};
zend_module_entry mymodule_module_entry = {
"mymodule",
mymodule_functions,
NULL,NULL,NULL,NULL,NULL,
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_MYMODULE
extern "C"
{
ZEND_GET_MODULE(mymodule)
}
#endif
PHP_FUNCTION(confirm_mymodule_compiled)
{
zval **arg;
int len;
char string[256];
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) ==
FAILURE)
{WRONG_PARAM_COUNT;}
convert_to_string_ex(arg);
len = sprintf(string, "Congratulations! You have successfully modified
ext/%.78s/config.m4. Module %.78s is now compiled into PHP.",
"mymodule", Z_STRVAL_PP(arg));
RETURN_STRINGL(string, len, 1);
}
---------------------------------------------------------------------------
Regards,
Atur Shah
------------------------------------------------------------------------
[2001-09-12 12:26:30] mfischer@php.net
Make sure your module entry is in the source
#ifdef COMPILE_DL_YOURMODULE
ZEND_GET_MODULE(yourmodule)
#endif
- Markus
------------------------------------------------------------------------
[2001-09-12 11:51:17] hholzgra@php.net
support problem and most likely not a bug (at least not enough info to
find out), please ask the phpdev mailing list (and give more info)
------------------------------------------------------------------------
[2001-09-12 11:40:45] atur at vigorsoft dot com
HI,
I am trying to load newly made PHP extension module (C++).
(e.g. mymodule.dll) using dl().
The error when accessing PHP file in browser with Apache Web Server is
:
"Invalid Library (Maybe not a PHP Library) mymodule.dll"
I used these configurations :
PHP 4.0.6
Apache 1.3.20
Windows NT 4.0
Visual C++ 6.0
Comments Please.
Thanks.
Atur Shah.
(aturshah@hotmail.com)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=13266&edit=1