faqts : Computers : Programming : Languages : PHP : Installation and Setup : Modules

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

25 of 41 people (61%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

Using self created DLLs / so in PHP

May 28th, 2002 18:56
Bex, Rolf Lehmann,


When I create a DLL with one simple function and I add this DLL to PHP, 
the DLL is found but instead of calling the function within, I get an 
error message:
Warning: Invalid library (maybe not a PHP3 library) 'phptest_dll.dll' 
in (null) on line (17)

When I look into the DLL with MS Dependency Viewer, I see two entries, 
one C_CALL the other STD_CALL.

When I look into i.e. php3_odbc.dll, I can see a function "get_module" 
in every single php DLL. Do I have to insert such a function into my 
own DLL, so it is recognised by PHP?

What else do I have to concern in using self written DLLs? Is there a 
documentation, since the manual is silent about this topic?

Thanks, Rolf.


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