Magickwand Extensions for PHP compiled on Windows

Source: Internet
Author: User
Tags imagemagick php source code vc9

First this is a lengthy process, and the user trying to compile this plugin must be patient. The approximate process can be divided into:

    1. Compiling ImageMagick

    2. Compiling Magickwand


About the PHP version. Windows PHP is the version of the VC compiled, this must be clear first, for example, my is VC9 compiled, then be sure to download the corresponding VC to compile. For example VC9 corresponds to VS2008,VC10 corresponding to VS2010.


The following cut to the chase:

  1. First download the source Code of PHP, note that the source of your download will be the same version of the PHP executable file on your Windows. For example, mine is 5.4.31RC1.

  2. Download ImageMagick source code, I write this article when the latest version is ImageMagick-6.8.9

  3. Download magickwandforphp source code, I write this article when the latest version is Magickwandforphp-1.0.9-2.zip
    (Note: The above source code suggestions are downloaded from the official, and if there is a corresponding version of Windows, download the Windows version.) If the Windows version is not marked clearly, the. zip format usually defaults to the Windows version of the source code. )

  4. First Compile Magickwand
    Magickwand's source code directory has a directory called Visualmagick, which contains the project files for vs. Double-click, upgrade to the solution of the VS version that you are using, and then open.
    The first compile, will inevitably encounter errors, if the final compilation has 5 or more than 5 items failed, it is necessary to check, and then modify the error after recompiling.
    The first time I compiled a 5 project did not compile successfully, resulting in some of the core of the Lib file failed to generate. In the right case, it should be that each sub-project has a Lib file and the corresponding DLL file is generated. The engineering of which the core begins is particularly important. If there is a im_mod at the beginning of the project did not succeed, it may have little impact on the back, can be ignored.

    Generally, the project files are not compiled successfully, may be interrelated, such as the compilation of Project A, may require project B's compiled lib file as support. The first time I compile, the reason for failure finally found is one of the multi-language features related to the module source files, there are national language text, but this source file encoding is not with the BOM UTF8, according to Microsoft's official explanation, the use of this UTF8 error in VS is unpredictable, With madedit added BOM, problem solving, and finally only a mod project has not been compiled successfully, can be ignored.

  5. Then compile the Magickwand
    First create a new solution, select Win32 DLL project (empty project), and then import the corresponding C files and h files under Magickwand.

    Add the corresponding include file directory:
    The directory where PHP source code resides
    Zend directory in the directory where PHP source code is located
    The main directory in the directory where the PHP source code resides
    TSRM directory in the directory where PHP source code is located
    ImageMagick Source Directory
    Magick directory in the directory where the ImageMagick source code is located

    Add the corresponding library file directory:
    The directory where the PHP executable file resides
    The extras directory in the directory where the PHP executable file resides
    The dev directory in the same directory as the PHP executable file
    Visualmagick\lib directory in the directory where the ImageMagick source code is located

    Enter the properties of the project file, expand the C + + > Preprocessor section, and include the following in the preprocessor definition:
    Zend_debug=0
    WIN32
    Ndebug
    _windows
    _usrdll
    Magickwand_exports
    Compile_dl_magickwand
    Zend_win32
    Php_win32
    Have_magickwand=1
    Libzend_exports

    Enter the connector > input section and add the following to the additional dependencies:
    Odbc32.lib
    Odbccp32.lib
    Php5embed.lib
    Core_rl_wand_.lib
    Core_rl_zlib_.lib
    Core_rl_webp_.lib
    Core_rl_ttf_.lib
    Core_rl_tiff_.lib
    Core_rl_png_.lib
    Core_rl_pixman_.lib
    Core_rl_openjpeg_.lib
    Core_rl_magick++_.lib
    Core_rl_magick_.lib
    Core_rl_lqr_.lib
    Core_rl_libxml_.lib
    Core_rl_lcms_.lib
    Core_rl_jpeg_.lib
    Core_rl_jp2_.lib
    Core_rl_jbig_.lib
    Core_rl_glib_.lib
    Core_rl_ffi_.lib
    Core_rl_croco_.lib
    Core_rl_cairo_.lib
    Core_rl_bzlib_.lib.
    Core_rl_librsvg_.lib

    At this point you can start to build the solution, the middle will definitely encounter an error, presumably a C + + compiler breakpoint, find the corresponding source code comments out. (Magickwand for Windows million does not update the code, only according to the error to adjust, if encountered other errors, the solution is similar)

  6. The last DLL file generated is the extension file annotated PHP, how to use no longer repeat. Finally, there are a few points to note:

    First of all, this method is dynamically linked by default, so it may be necessary to include in our environment variables the Visualmagick\bin directory in the directory where the ImageMagick source code is located, which is the directory where ImageMagick compiled the DLLs. To properly load this PHP extension, of course, users can also choose to compile the full static connection.

    Next is, the download PHP source code, most likely there is a macro definition: #define PHP_COMPILER_ID "VC9", if you encounter this situation, change to your own version of the compiler, or the last load may be prompted version can not be docked.

    Finally, be sure to use NTS, that is, non-thread-safe compilation, generally speaking, Windows PHP must use a non-thread-safe version.







This article is from the "records only" blog, so be sure to keep this source http://dajyaretakuya.blog.51cto.com/2823475/1537516

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.