Questions about compiling PHP extension components on Windows

Source: Internet
Author: User
Problems compiling PHP extension components on Windows

?

These two days need to compile a php extension to achieve a specific function, referring to the online n multiple articles, and finally found two pieces of treasure, one is Php_screw, the other is Cygwin.
First compile the php_screw, in order to have a perceptual impression, compile through no problem, and then try to add some code, the final bump to compile successfully. But put to Apache on trial, but often appear memory read and write exception, repair modification changed for a long time has not been able to solve.

So, want to start all over again, refer to Php_screw to add a little bit of code to see if you can solve the problem.
According to the online tutorial, use the command in Cygwin:
? PHP ext_skel_win32.php--extname=mytest
Build the test program framework, and then directly compile the framework, everything is smooth, and then add a function to the Apache test, and also normal, but to the following two functions:
Php_minit_function (mytest)
And
Php_mshutdown_function (mytest)
Return SUCCESS in front of the add
CG (Extended_info) = 1;
, and then compile, a compilation error occurs:

Deleting intermediate files and output files for project ' Mytest-win32 debug_ts '.--------------------configuration:myte St-win32 debug_ts--------------------compiling...mytest.clinking   ... Creating library Debug_ts/php_mytest.lib and Object Debug_ts/php_mytest.expmytest.obj:error lnk2001:unresolved External symbol _COMPILER_GLOBALS_ID. \.. \debug_ts/php_mytest.dll:fatal error lnk1120:1 unresolved externalserror executing link.exe.Creating browse info file: . Php_mytest.dll-2 error (s), 0 warning (s)

?

Online search for a long time, I tried not to, so suspicion is the compiler configuration problem, so open php_screw and mytest two projects, on the compilation parameters of an item, and finally found:
automatically generated compilation parameters as follows project--Setting-C + +-->preprocessor definitions::
zend_debug=1 , Win32,ndebug,_windows,_mbcs,_usrdll,mytest_ Exports, Compile_dl_mytest,zts=1,zend_win32,php_win32,have_mytest=1, Libzend_exports
and Php_screw's corresponding parameters are as follows:
Zend_debug=0,win32,ndebug,_windows,_mbcs,_usrdll, Screw_exports, Compile_dl_screw, Zts=1,zend_win32,php_win32,have_screw=1
, the contrast can be found:
1, automatically generate frame zend_debug=1, And the zend_debug=0 of Php_screw;
2, the parameters of the auto-generated frame one more libzend_exports;
I then test the two parameters separately:
1, change the zend_debug=1 to Zend_debug=0, and then compile, the error is as follows:

Deleting intermediate files and output files for project ' Mytest-win32 debug_ts '.--------------------configuration:myte St-win32 debug_ts--------------------compiling...mytest.clinking   ... Creating library Debug_ts/php_mytest.lib and Object Debug_ts/php_mytest.expmytest.obj:error lnk2001:unresolved External symbol _COMPILER_GLOBALS_ID. \.. \debug_ts/php_mytest.dll:fatal error lnk1120:1 unresolved externalserror executing link.exe.Creating browse info file: . Php_mytest.dll-2 error (s), 0 warning (s)

?

2, then the libzend_exports removed, and then compiled, the error disappears:

Deleting intermediate files and output files for project ' Mytest-win32 debug_ts '.--------------------configuration:myte St-win32 debug_ts--------------------compiling...mytest.clinking   ... Creating library Debug_ts/php_mytest.lib and object debug_ts/php_mytest.expcreating Browse info File...php_mytest.dll- 0 error (s), 0 warning (s)

?

3, re-zend_debug=0 to Zend_debug=1, and then compile, error-free:

Deleting intermediate files and output files for project ' Mytest-win32 debug_ts '.--------------------configuration:myte St-win32 debug_ts--------------------compiling...mytest.clinking   ... Creating library Debug_ts/php_mytest.lib and object debug_ts/php_mytest.expcreating Browse info File...php_mytest.dll- 0 error (s), 0 warning (s)

?

Therefore, the problem is due to the Libzend_exports parameter, but because of the VC is not familiar with the Zend API more unfamiliar reason, can only be known but not know its why also;

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.