2

我正在尝试编译 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 网站上找不到旧版本存档

4

2 回答 2

5
$ 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 :(";
于 2015-06-27T05:53:32.653 回答
4

实际上我发现了这两个问题

1) Ubuntu 有一个 CImg 包,可以很好地安装

$ sudo apt-get install cimg-dev

2) pthread错误可以通过在configure脚本中添加一个LDFLAGS参数来解决。

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

现在我有一个 php 扩展编译问题,但这是另一个故事(叹气):php 扩展使用比我的 PHP 更新的 API 版本编译

于 2014-03-05T21:24:57.247 回答