2

I'm trying to compile the pHash extension. I found a great step-by-step explanation here, https://serverfault.com/questions/491730/compile-phash-on-centos-php-extension

But I'm bumping into two problems :

1) When launching the ./configure script of the pHash sources, the log shows the following error, although I copied CImg.h in my /usr/local/include folder

*** Configuring image hash ***

checking CImg.h usability... no
checking CImg.h presence... no
checking for CImg.h... no
checking whether CImg.h is in the current or src directory.... no

Which is really a bummer, as I'm most interested in the pHash DCT image hashing algorithm function

2) pHash compilation fails with the following error when launching make :

../src/.libs/libpHash.so: undefined reference to `pthread_create'
../src/.libs/libpHash.so: undefined reference to `pthread_join'
collect2: ld returned 1 exit status
make[2]: *** [test_texthash] Error 1
make[2]: Leaving directory `/home/downloads/libraries/pHash-0.9.6/examples'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/downloads/libraries/pHash-0.9.6'
make: *** [all] Error 2

Any idea why this is happening? I made sure all the dependencies are met as stated in the link above. I would like to try with pHash-0.9.5, but I could not find older version archives on the phash.org website

Community
  • 1
  • 1
joseph-l
  • 91
  • 1
  • 6

2 Answers2

5
$ sudo apt-get install make libsndfile-dev checkinstall
$ sudo apt-get install cimg-dev libjpeg62 libfftw3-3 imagemagick graphicsmagick

download libpng

$ tar xvf libpng-1.5.18.tar.gz
$ cd libpng-1.5.18
$ ./configure
$ make check
$ make install
$ sudo apt-get install libsamplerate0-dev libmpg123-dev
$ cd

download pHash

$ tar xvf pHash-0.9.6.tar.gz
$ cd pHash-0.9.6
$ ./configure --enable-openmp=yes --enable-video-hash=no LIBS='-lpthread'
$ make
$ sudo checkinstall --pkgname=phash --pkgversion="1:$(date +%Y%m%d%H%M)-0.9.6" --backup=no \
  --deldoc=yes --fstrans=no --default
$ cd
$ git clone --depth=1 http://github.com/Alexis2004/php-phash
$ cd php-phash
$ pear install CodeGen_PECL
$ ./compile.sh
$ make test
$ make install

This works... All you have to do now is to add 'extension=pHash.so' to your php.ini file(s), and you're good to go!

test it with following code

if (extension_loaded("pHash"))
    echo "pHash loaded :)";
  else
    echo "something is wrong :(";
Kumaran
  • 3,460
  • 5
  • 32
  • 34
4

Actually I figured out both problems

1) Ubuntu has a CImg package which installs just fine with

$ sudo apt-get install cimg-dev

2) the pthread error can be solved by adding a LDFLAGS parameter to the configure script.

$ ./configure --enable-openmp=yes --enable-video-hash=no --enable-audio-hash=no LDFLAGS='-lpthread'

Now I have a php extension compiling problem, but that's another story (sigh) : php extension compiles with newer API version than my PHP

Community
  • 1
  • 1
joseph-l
  • 91
  • 1
  • 6