我正在尝试编译pHash扩展名。我在这里找到了很棒的逐步说明https://serverfault.com/questions/491730/compile-phash-on-centos-php-extension

但是我遇到了两个问题:

1)启动pHash源的./configure脚本时,尽管我在/usr/local/include文件夹中复制了CImg.h,但日志显示以下错误

*** 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

这真是一个无赖,因为我对pHash DCT图像哈希算法功能最感兴趣

2)启动make时,pHash编译失败并显示以下错误:
../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

知道为什么会这样吗?我确保按照上面的链接所述满足所有依赖性。
我想尝试使用pHash-0.9.5,但在phash.org网站上找不到较旧的版本文件

最佳答案

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

下载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

下载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

这有效...
您现在要做的就是将“extension = pHash.so”添加到您的php.ini文件中,您一切顺利!

用以下代码对其进行测试
if (extension_loaded("pHash"))
    echo "pHash loaded :)";
  else
    echo "something is wrong :(";

关于c++ - 在Ubuntu + PHP扩展上编译pHash,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22195898/

10-12 16:16