-2

I try to use the GMP library for big integers in PHP.
I use XAMPP, PHP 5.5.11, and Ubuntu 14.04.

According to several sources it should be as easy as that:

run sudo apt-get install php5-gmp
put extension=php_gmp.so or extension=gmp.so in php.ini
restart XAMPP

Then it should work, and in phpinfo() I should see the GMP version.
But nothing works. I also tried the rather unhelpful hints in the installation guide.

What's wrong?

Watchduck
  • 1,076
  • 1
  • 9
  • 29
  • 1
    "What's wrong?" We don't know. You tell us... – PeeHaa Oct 26 '14 at 22:13
  • I mean: What kind of tests could I run, to find out, why the steps that worked for others don't work for me? – Watchduck Oct 26 '14 at 22:17
  • 1
    1.) Check if the library has been installed by apt-get. 2.) Check if you're editing the right php.ini 3.) Check PHP startup errors. – hakre Oct 26 '14 at 23:03
  • 3.)I indeed have a PHP startup error: `[27-Oct-2014 00:33:42 Europe/Berlin] PHP Warning: PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20121212/gmp.so' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20121212/gmp.so: cannot open shared object file: No such file or directory in Unknown on line 0` – Watchduck Oct 26 '14 at 23:35
  • So the software expected `/opt/lampp/lib/php/extensions/no-debug-non-zts-20121212/gmp.so`, and I had `/usr/lib/php5/20121212/gmp.so`. I copied it there, and now it works. Thanks for the hint with the startup errors. I don't get, why you downvote my question. Sometimes further investigation needs a little hint where to look, like the one I just got. – Watchduck Oct 26 '14 at 23:58

2 Answers2

2

Uncomment extension=php_gmp.dll line. To uncomment simply remove ;

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
Daud khan
  • 2,413
  • 2
  • 14
  • 18
0

The hint that has answered this question for me was given by hakre in a comment:

If the installation has worked, and the right php.ini was edited, but after restart of XAMPP there is still the Fatal error: Call to undefined function gmp_foo() in /opt/lampp/htdocs/bar/barf.php on line 123, it may be a good idea to look for startup errors in the PHP error log. For me it was in /opt/lampp/logs/php_error_log.

There it showed the same error after every restart of XAMPP. As shown in the comments, the problem was that gmp.so was not in the expected folder. After I copied it there, everything worked, and in the phpinfo() is now a gmp section with the entries:
gmp support enabled
GMP version 5.1.3

Watchduck
  • 1,076
  • 1
  • 9
  • 29