8

I am trying to install Lapack to use it with PHP (http://php.net/manual/en/book.lapack.php) as it is the only PHP library that I have found that contains computations for singular values.

I am on a Ubuntu 14.04 server with Apache2.

I have installed gfortran and liblapack-dev as instructed on other websites, but they all stop short of describing how to include it. In short, I get an qerror when calling a static function from Lapack, saying that it is not a defined class.

I figure that my next step is enabling the extension, but despite following this question (How to check which PHP extensions have been enabled/disabled in Ubuntu Linux 12.04 LTS?) I found no mention of Lapack. How should I resume to install Lapack for PHP? Thanks!

Community
  • 1
  • 1
MemoNick
  • 501
  • 2
  • 7
  • 20
  • 1
    Unless you find someone who has created a binary package for your Ubuntu version, I'm afraid you'll have to install the C development packages and compile the extension yourself as instructed in the PHP manual. (I strongly suggest you look for a binary package first.) – Álvaro González Oct 17 '16 at 14:57
  • Did you check that you were in the right php config file? (Sometimes, the CGI and the CLI don't use the same php.ini). You can check the phpinfo(); function both in your console and in your browser to make sure the extension is enabled in both environments. – Boulzy Oct 17 '16 at 15:00

1 Answers1

3

Installing Lapack from source

Note: Tested on Ubuntu 16.04.

Install prerequisites:

sudo apt-get install php5-dev git svn cmake gfortran liblapack-dev

Follow the instructions here (copied for convenience):

svn co https://icl.cs.utk.edu/svn/lapack-dev/lapack/trunk lapack
cd lapack
mkdir build
cd build
cmake -D BUILD_SHARED_LIBS=ON -D LAPACKE=ON ../
make 
sudo make install

This will create the Lapack shared library. Now clone the php extension from source:

git clone https://github.com/ianbarber/php-lapack

And follow the instructions as described there:

cd php-lapack
phpize
./configure
make 
sudo make install

Check if the extension is installed: php -m | grep -i lapack

Note that the extension is most likely incompatible with PHP 7, as it has not been updated for over 5 years.

Pieter van den Ham
  • 4,381
  • 3
  • 26
  • 41
  • 1
    This is what I meant with *install the C development packages and compile the extension yourself*. And a pretty good explanation, if you want my opinion. – Álvaro González Oct 19 '16 at 14:22