[Solved] PHP Startup Unable to initialize module

Problems with the Windows version of XAMPP, questions, comments, and anything related.

[Solved] PHP Startup Unable to initialize module

Postby pylonx » 01. April 2013 20:49

I Searched and couldn't find quite what I was looking for. Please leave me a link if I've missed the info. Sorry and Thank you.

I recently upgraded from XAMPP 1.7.3 to 1.8.1. This is a change that was needed for the newer versions of APACHE and MySQL.
Currently I am working on a Windows 7 Pro Machine, but I will be installing it on a Windows XP Pro and a Windows Server 2008 r2.
One of the most important pieces to my script is the ability to print RAW data to printers using the printer functions by way of php_printer.dll
Code: Select all
printer_set_option($handle, PRINTER_MODE, "RAW");


After receiving the error: " Fatal error: Call to undefined function printer_open() in ~". I checked the php_error_log and received the following information.

PHP Warning: PHP Startup: printer: Unable to initialize module
Module compiled with module API=20090626
PHP compiled with module API=20100525
These options need to match


I've looked for hours trying to find a pre-compiled php_printer.dll for PHP 5.4.7 to no avail. I have concluded that I will have to compile it from source files in the PECL. http://pecl.php.net/package/printer
Having never had to do this before I did what any internet user should do. I googled it and found some information.

https://wiki.php.net/internals/windows/stepbystepbuild

http://board.phpbuilder.com/showthread.php?10374806-How-to-compile-PHP-from-Source-on-Windows

But both of these are outdated and aren't from the stand point of a XAMPP user. I feel like I've used the simplicity of XAMPP as a crutch and feel very much out of my league. So, I'm hoping for 1 of 2 things. That some one might be able to help me compile a dll correctly for XAMPP 1.8.1 / PHP 5.4.7. Or that someone is already set up to compile dlls for XAMPP 1.8.1 and can quickly compile a php_printer.dll.

Thank you for your time, Greatly appreciated.
Last edited by pylonx on 31. July 2013 16:29, edited 1 time in total.
pylonx
 
Posts: 18
Joined: 19. October 2010 19:02
XAMPP Version: 1.8.3-1
Operating System: Win7PRO, WinSrv2012

Re: PHP Startup Unable to initialize module

Postby Altrea » 02. April 2013 09:35

Hi pylonx,

Please start new threads with the words "Hi" or "Hello". A short salutation is an act of politeness. Even if the internet is an virtual area, there is always a human being behind the screen. A polite beginning is the first positive impression you can leave here and helps to get polite answers too. Please keep that in mind if you start a new thread in any community board. Thank you.

pylonx wrote:https://wiki.php.net/internals/windows/stepbystepbuild

http://board.phpbuilder.com/showthread.php?10374806-How-to-compile-PHP-from-Source-on-Windows

But both of these are outdated and aren't from the stand point of a XAMPP user.

Why do you think they are outdated? Even they focussed on compiling PHP 5.3 i don't expect any big differences in doing so with PHP 5.4 (and the first ressource gives you helpful information on the differences even for PHP 5.5).
XAMPP is based on the precompiled resources of php.net. How should this be better written for XAMPP users?

pylonx wrote:That some one might be able to help me compile a dll correctly for XAMPP 1.8.1 / PHP 5.4.7.

Simply try it out :)

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6474
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: PHP Startup Unable to initialize module

Postby pylonx » 02. April 2013 17:18

Hello Xampp Forums!

I'm a mediocre PHP scripter, Video Gamer, computer builder that was blessed to get a job as an Manager of Information Systems for a small sporting goods retail chain out of Idaho. I've been very busy trying to get us up to PCI compliant standards and was hoping there was a way to spend less time on this particular issue.

Questions:
Does it matter which Binaries I use from http://windows.php.net/downloads/php-sdk/ ?
There are two:
20110512 and 20110915
I am worried that because neither of these match the "PHP compiled with module API=20100525" date that I will end up with a similar problem.

The first steps are for building PHP, I don't necessarily want to build PHP I just want to create the extension. Do I still need to do the beginning steps or can I skip straight down to the "Adding PECL extensions (using 'dbase' as an example)" step?

Anyhow, as you say, I'll try it out and and report the outcome. Thank you for your reply!
pylonx
 
Posts: 18
Joined: 19. October 2010 19:02
XAMPP Version: 1.8.3-1
Operating System: Win7PRO, WinSrv2012

Re: PHP Startup Unable to initialize module

Postby pylonx » 03. April 2013 00:22

Hello Interwebs,

It only took me all day, and now still stuck.

I did as shown on this site:
https://wiki.php.net/internals/windows/stepbystepbuild

And the build worked. Then I tried to create the php_printer.dll
First I tried :
Code: Select all
svn co http://svn.php.net/repository/pecl/dbase/trunk pecl/dbase

But it said:
'svn' is not recognized as an internal or external command, operable program or batch file.

So I just downloaded the files myself from:
http://svn.php.net/repository/pecl/printer/trunk/
and put them in:
C:\php-sdk\php54dev\vc9\x86\php5.4-201303311430\ext\printer

made sure to download the libraries both from:
http://windows.php.net/downloads/php-sdk/deps/vc9/x86/
Also just the:
deps-5.4-vc9-x86.7z

I tried one then the other every time I received:

Code: Select all
c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430>nmake

Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

printer.c
ext\printer\printer.c(266) : error C2065: 'pval' : undeclared identifier
ext\printer\printer.c(266) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(266) : error C2100: illegal indirection
ext\printer\printer.c(266) : warning C4552: '*' : operator has no effect; expect
ed operator with side-effect
ext\printer\printer.c(267) : error C2275: 'printer' : illegal use of this type a
s an expression
        c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430\ext\printer\php_printer.
h(78) : see declaration of 'printer'
ext\printer\printer.c(267) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(269) : error C2143: syntax error : missing ';' before 'typ
e'
ext\printer\printer.c(271) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(271) : warning C4047: '=' : 'int' differs in levels of ind
irection from 'printer *'
ext\printer\printer.c(272) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(272) : error C2223: left of '->dmModifiedFields' must poin
t to struct/union
ext\printer\printer.c(274) : error C2065: 'argc' : undeclared identifier
ext\printer\printer.c(274) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(275) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(275) : error C2100: illegal indirection
ext\printer\printer.c(275) : error C2100: illegal indirection
ext\printer\printer.c(275) : error C2224: left of '.type' must have struct/union
 type
ext\printer\printer.c(275) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(275) : error C2100: illegal indirection
ext\printer\printer.c(275) : warning C4047: 'function' : 'zval *' differs in lev
els of indirection from 'int'
ext\printer\printer.c(275) : warning C4024: 'zval_isref_p' : different types for
 formal and actual parameter 1
ext\printer\printer.c(275) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(275) : error C2100: illegal indirection
ext\printer\printer.c(275) : warning C4047: 'function' : 'zval *' differs in lev
els of indirection from 'int'
ext\printer\printer.c(275) : warning C4024: 'zval_refcount_p' : different types
for formal and actual parameter 1
ext\printer\printer.c(275) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(275) : error C2100: illegal indirection
ext\printer\printer.c(275) : warning C4047: 'function' : 'zval *' differs in lev
els of indirection from 'int'
ext\printer\printer.c(275) : warning C4024: 'zval_delref_p' : different types fo
r formal and actual parameter 1
ext\printer\printer.c(275) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(275) : error C2100: illegal indirection
ext\printer\printer.c(275) : error C2223: left of '->value' must point to struct
/union
ext\printer\printer.c(275) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(275) : error C2100: illegal indirection
ext\printer\printer.c(275) : error C2100: illegal indirection
ext\printer\printer.c(275) : error C2224: left of '.type' must have struct/union
 type
ext\printer\printer.c(275) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(275) : error C2100: illegal indirection
ext\printer\printer.c(275) : warning C4047: '=' : 'int' differs in levels of ind
irection from 'zval *'
ext\printer\printer.c(275) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(275) : error C2100: illegal indirection
ext\printer\printer.c(275) : error C2223: left of '->type' must point to struct/
union
ext\printer\printer.c(275) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(275) : error C2100: illegal indirection
ext\printer\printer.c(275) : warning C4047: 'function' : 'zval *' differs in lev
els of indirection from 'int'
ext\printer\printer.c(275) : warning C4024: '_convert_to_string' : different typ
es for formal and actual parameter 1
ext\printer\printer.c(276) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(276) : error C2223: left of '->name' must point to struct/
union
ext\printer\printer.c(276) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(276) : error C2100: illegal indirection
ext\printer\printer.c(276) : error C2100: illegal indirection
ext\printer\printer.c(276) : error C2224: left of '.value' must have struct/unio
n type
ext\printer\printer.c(278) : error C2065: 'argc' : undeclared identifier
ext\printer\printer.c(279) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(279) : error C2223: left of '->name' must point to struct/
union
ext\printer\printer.c(285) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(285) : error C2223: left of '->name' must point to struct/
union
ext\printer\printer.c(285) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(285) : error C2223: left of '->handle' must point to struc
t/union
ext\printer\printer.c(285) : error C2198: 'OpenPrinterA' : too few arguments for
 call
ext\printer\printer.c(286) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(286) : error C2223: left of '->pi2' must point to struct/u
nion
ext\printer\printer.c(287) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(287) : error C2223: left of '->pi2' must point to struct/u
nion
ext\printer\printer.c(287) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(287) : error C2223: left of '->name' must point to struct/
union
ext\printer\printer.c(287) : error C2198: 'DocumentPropertiesA' : too few argume
nts for call
ext\printer\printer.c(288) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(288) : error C2223: left of '->handle' must point to struc
t/union
ext\printer\printer.c(288) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(288) : error C2223: left of '->name' must point to struct/
union
ext\printer\printer.c(288) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(288) : error C2223: left of '->pi2' must point to struct/u
nion
ext\printer\printer.c(288) : warning C4047: 'function' : 'LPSTR' differs in leve
ls of indirection from 'int'
ext\printer\printer.c(288) : warning C4024: 'DocumentPropertiesA' : different ty
pes for formal and actual parameter 3
ext\printer\printer.c(288) : error C2198: 'DocumentPropertiesA' : too few argume
nts for call
ext\printer\printer.c(289) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(289) : error C2223: left of '->info' must point to struct/
union
ext\printer\printer.c(290) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(290) : error C2223: left of '->info' must point to struct/
union
ext\printer\printer.c(291) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(291) : error C2223: left of '->info' must point to struct/
union
ext\printer\printer.c(292) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(292) : error C2223: left of '->info' must point to struct/
union
ext\printer\printer.c(293) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(293) : error C2223: left of '->info' must point to struct/
union
ext\printer\printer.c(293) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(293) : error C2223: left of '->info' must point to struct/
union
ext\printer\printer.c(294) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(294) : error C2223: left of '->dc' must point to struct/un
ion
ext\printer\printer.c(294) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(294) : error C2223: left of '->name' must point to struct/
union
ext\printer\printer.c(294) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(294) : error C2223: left of '->pi2' must point to struct/u
nion
ext\printer\printer.c(294) : error C2198: 'CreateDCA' : too few arguments for ca
ll
ext\printer\printer.c(295) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(295) : warning C4022: 'zend_register_resource' : pointer m
ismatch for actual parameter 2
ext\printer\printer.c(299) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(299) : error C2223: left of '->name' must point to struct/
union
ext\printer\printer.c(310) : error C2065: 'pval' : undeclared identifier
ext\printer\printer.c(310) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(310) : error C2100: illegal indirection
ext\printer\printer.c(310) : warning C4552: '*' : operator has no effect; expect
ed operator with side-effect
ext\printer\printer.c(311) : error C2275: 'printer' : illegal use of this type a
s an expression
        c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430\ext\printer\php_printer.
h(78) : see declaration of 'printer'
ext\printer\printer.c(311) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(313) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(317) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(317) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(317) : warning C4047: 'function' : 'zval **' differs in le
vels of indirection from 'int'
ext\printer\printer.c(317) : warning C4024: 'zend_fetch_resource' : different ty
pes for formal and actual parameter 1
ext\printer\printer.c(317) : warning C4047: '=' : 'int' differs in levels of ind
irection from 'printer *'
ext\printer\printer.c(317) : error C2065: 'resource' : undeclared identifier
ext\printer\printer.c(319) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(319) : error C2100: illegal indirection
ext\printer\printer.c(319) : error C2100: illegal indirection
ext\printer\printer.c(319) : error C2224: left of '.value' must have struct/unio
n type
ext\printer\printer.c(319) : warning C4047: 'function' : 'int' differs in levels
 of indirection from 'void ***'
ext\printer\printer.c(319) : warning C4024: '_zend_list_delete' : different type
s for formal and actual parameter 1
ext\printer\printer.c(319) : error C2198: '_zend_list_delete' : too few argument
s for call
ext\printer\printer.c(328) : error C2065: 'pval' : undeclared identifier
ext\printer\printer.c(328) : error C2065: 'arg1' : undeclared identifier
ext\printer\printer.c(328) : fatal error C1003: error count exceeds 100; stoppin
g compilation
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\
VC\Bin\cl.exe"' : return code '0x2'
Stop.


Please help!
pylonx
 
Posts: 18
Joined: 19. October 2010 19:02
XAMPP Version: 1.8.3-1
Operating System: Win7PRO, WinSrv2012

Re: PHP Startup Unable to initialize module

Postby hackattack142 » 03. April 2013 22:51

Hello,

Open 'printer.c' and replace all instances of 'pval' with 'zval' and it should compile.
XAMPP Control Panel Developer
Latest CP: viewtopic.php?f=16&t=48932
hackattack142
 
Posts: 701
Joined: 20. May 2011 23:29
XAMPP Version: 5.6.3
Operating System: Windows 7 Ultimate SP1 64-Bit

Re: PHP Startup Unable to initialize module

Postby pylonx » 04. April 2013 21:48

Thank you Hackattack, one step closer I hope,

Code: Select all
c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430>buildconf
~
c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430>configure --disable-all --enable-cli --enable-printer
~
c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430>nmake

Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

internal_functions.c
printer.c
   Creating library Release_TS\php5ts.lib and object Release_TS\php5ts.exp
   Creating library Release_TS\php.lib and object Release_TS\php.exp
SAPI sapi\cli build complete


It seemed to have compiled. However; I can't find a printer.dll or a php_printer.dll which is the outcome I was hoping for.

In the Release_TS\ext folder there is a folder named Printer. It contains the following Files:
printer.obj
printer.sbr
vc90.idb


I also did the last step:
Code: Select all
c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430>cd Release_TS

c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430\Release_TS>php -m
[PHP Modules]
Core
date
ereg
pcre
printer
Reflection
SPL
standard

[Zend Modules]


c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430\Release_TS>
pylonx
 
Posts: 18
Joined: 19. October 2010 19:02
XAMPP Version: 1.8.3-1
Operating System: Win7PRO, WinSrv2012

Re: PHP Startup Unable to initialize module

Postby hackattack142 » 04. April 2013 23:58

Hello,

You need to compile it as a shared library and not statically (static is the default and compiles the functionality directly into PHP which is why it appears in your final output of PHP modules)

On your configure line:
Code: Select all
configure --disable-all --enable-cli --enable-printer=shared
XAMPP Control Panel Developer
Latest CP: viewtopic.php?f=16&t=48932
hackattack142
 
Posts: 701
Joined: 20. May 2011 23:29
XAMPP Version: 5.6.3
Operating System: Windows 7 Ultimate SP1 64-Bit

Re: PHP Startup Unable to initialize module

Postby pylonx » 10. April 2013 22:41

Thanks Hackattack142!

That did the trick. I built the php_printer.dll with your help.

I won't be able to test it until the weekend when no one is using that server. I will post again either way, success or another failure.

Thanks Again!
pylonx
 
Posts: 18
Joined: 19. October 2010 19:02
XAMPP Version: 1.8.3-1
Operating System: Win7PRO, WinSrv2012

Re: PHP Startup Unable to initialize module

Postby pylonx » 15. April 2013 16:40

Installed Xampp 1.8.1 again.
Threw the php_printer.dll in the php\ext DIR.
Put extension=php_printer.dll in the php.ini
Started Apache

In PHP Error Log:
[15-Apr-2013 15:34:53 UTC] PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'php_printer.dll' in Unknown on line 0

AND

[15-Apr-2013 15:35:13 UTC] PHP Fatal error: Call to undefined function printer_open() in C:\xampp\htdocs\.....
pylonx
 
Posts: 18
Joined: 19. October 2010 19:02
XAMPP Version: 1.8.3-1
Operating System: Win7PRO, WinSrv2012

Re: PHP Startup Unable to initialize module

Postby hackattack142 » 16. April 2013 02:15

Hello,

1. Open your "c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430\NEWS" file and tell me what the PHP version at the top says.

2. After you type "configure" at the prompt, what is the final output box for you? It will look similar to this:
Code: Select all
--------------------------------------------
|               |                          |
--------------------------------------------
| Build type    | Release                  |
| Thread Safety | Yes                      |
| Compiler      | MSVC10 (Visual C++ 2010) |
| Architecture  | x86                      |
-------------------------------------------
XAMPP Control Panel Developer
Latest CP: viewtopic.php?f=16&t=48932
hackattack142
 
Posts: 701
Joined: 20. May 2011 23:29
XAMPP Version: 5.6.3
Operating System: Windows 7 Ultimate SP1 64-Bit

Re: PHP Startup Unable to initialize module

Postby pylonx » 16. April 2013 16:25

Hi hackattack142,

Code: Select all
PHP                                                                        NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2013, PHP 5.4.15


Code: Select all
-------------------------------------------
|               |                         |
-------------------------------------------
| Build type    | Release                 |
| Thread Safety | Yes                     |
| Compiler      | MSVC9 (Visual C++ 2008) |
| Architecture  | x86                     |
-------------------------------------------
pylonx
 
Posts: 18
Joined: 19. October 2010 19:02
XAMPP Version: 1.8.3-1
Operating System: Win7PRO, WinSrv2012

Re: PHP Startup Unable to initialize module

Postby hackattack142 » 16. April 2013 22:56

Hello,

I tweaked my build environment to be compatible with XAMPP and was able to successfully build and load the DLL into PHP (shows up on my phpinfo page).

I suspect you need to use the correct PHP source version. XAMPP 1.8.1 uses PHP 5.4.7. If you don't want to bother with the PHP GIT repository, you can grab the correct source version here: http://www.oldapps.com/php_programming_ ... d_php=8227

Extract the php-5.4.7 folder to 'php-sdk\php54dev\vc9\x86\', copy the printer files from the other folder, and redo steps 6-8 and 12-16 under Setup while using the appropriate configure line for printer support.

*Note: when I did my compile, I just used "configure --enable-printer=shared" and did not disable anything.
XAMPP Control Panel Developer
Latest CP: viewtopic.php?f=16&t=48932
hackattack142
 
Posts: 701
Joined: 20. May 2011 23:29
XAMPP Version: 5.6.3
Operating System: Windows 7 Ultimate SP1 64-Bit

Re: PHP Startup Unable to initialize module

Postby LimitMan » 31. May 2013 14:21

Thanks for this post ppl. Compiled it successfully and it's working!
Free to download compiled version at:
http://www.webcentral.rs/php/php_printer.dll
LimitMan
 
Posts: 1
Joined: 31. May 2013 14:18
XAMPP Version: 5.6.3
Operating System: Windows XP/7

Re: PHP Startup Unable to initialize module

Postby pylonx » 17. June 2013 23:17

Hackattack142,

Thank you. I haven't been able to work on this project for a while. But over this last weekend I was able to create php_printer.dll and my code is now working great!

Thank you so much!

PHP Version 5.4.7 php_printer.dll
http://pylonx.com/PHP/php_printer.zip
pylonx
 
Posts: 18
Joined: 19. October 2010 19:02
XAMPP Version: 1.8.3-1
Operating System: Win7PRO, WinSrv2012

Re: [Solved] PHP Startup Unable to initialize module

Postby mortypk » 02. May 2014 16:00

PHP Version 5.4.7 php_printer.dll
http://pylonx.com/PHP/php_printer.zip
can you refresh this link as its now expire.
mortypk
 
Posts: 1
Joined: 02. May 2014 15:57
XAMPP Version: 5.6.3
Operating System: windows 7

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 32 guests