Search code examples
phpphp-extensiongmplamppphpize

config.m4 file is missing when compiling gmp php extension in lampp suite


I am trying to compile the gmp for lampp suite with php 7.1.7 with api version 20160303 . I downloaded gmp-6.1.2.tar.bz2 used
bzip2 -dk gmp-6.1.2.tar.bz2
to get tar file then tar -xvvf gmp-6.1.2.tar then cd gmp-6.1.2/.
When i run
/opt/lampp/bin/phpize (i am using lampp suite for dev), I got this

Cannot find config.m4. 
Make sure that you run '/opt/lampp/bin/phpize' in the top level source directory of the module

I am trying to compile gmp for php7.1.7.

Without running /opt/lampp/bin/phpize, and following these steps

  1. ./configure
  2. make
  3. make test
  4. make install
Its all compiling without any error with api version 20151012 but my php say its needs 20160303

Running php on console, I am getting this:

PHP Warning:  PHP Startup: gmp: Unable to initialize module
Module compiled with module API=20151012
PHP    compiled with module API=20160303
These options need to match
 in Unknown on line 0

Warning: PHP Startup: gmp: Unable to initialize module
Module compiled with module API=20151012
PHP    compiled with module API=20160303
These options need to match
 in Unknown on line 0

Solution

  • based on your comments, in order to compile a specific version of GMP extension, you will need to clone the PHP-SRC repository, and compile the PHP GMP extension.

    git clone git@github.com:php/php-src.git
    

    you may clone a the targeted branch rather that cloning the whole repository

    git clone -b PHP-7.1.7 git@github.com:php/php-src.git --depth 1
    

    then go to the GMP extension directory & phpize the extension and complete your compilation steps.

    cd php-src/ext/gmp
    phpize
    ./configure
    make
    sudo make install