我正在尝试编译pHash扩展。我在这里找到了一个很好的循序渐进的解释,https://serverfault.com/questions/491730/compile-phash-on-centos-php-extension
但我遇到了两个问题:
1)启动本地源代码的./configure脚本时,日志显示以下错误,尽管我在/usr/ pHash /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网站上找不到旧版本的归档文件
发布于 2015-06-27 13:53:33
$ 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 :(";发布于 2014-03-06 05:24:57
实际上我把这两个问题都解决了
1) Ubuntu有一个CImg包,它可以很好地安装
$ sudo apt-get install cimg-dev2) pthread错误可以通过在配置脚本中添加LDFLAGS参数来解决。
$ ./configure --enable-openmp=yes --enable-video-hash=no --enable-audio-hash=no LDFLAGS='-lpthread'现在我有一个php扩展编译问题,但那是另一回事了(叹息):php extension compiles with newer API version than my PHP
https://stackoverflow.com/questions/22195898
复制相似问题