Home  >  Article  >  Backend Development  >  编译mcrypt出错,mhash怎么都对不上(已解决)

编译mcrypt出错,mhash怎么都对不上(已解决)

WBOY
WBOYOriginal
2016-06-06 20:52:471601browse

想自己编译安装php的mcrypt扩展

# libmcrypt
tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/home/felix021/lamp/libmcrypt/
make
make install

# mhash
tar jxf mhash-0.9.9.9.tar.bz2
cd mhash-0.9.9.9
./configure --prefix=/home/felix021/lamp/mhash/
make
make install

# mcrypt
LD_LIBRARY_PATH=/home/felix021/lamp/libmcrypt/lib:/home/felix021/lamp/mhash/lib
./configure --prefix=/home/felix021/lamp/mcrypt/ --with-libmcrypt-prefix=/home/felix021/lamp/libmcrypt

configure不通过,提示:

checking for mhash_keygen in -lmhash... no
configure: error: "You need at least libmhash 0.8.15 to compile this program. http://mhash.sf.net/"

于是专门去找了mhash0.8.18和mhash0.8.15,依然是这个错误。

查了一下mhash_keygen这个函数,在0.8.15/8中是
int mhash_keygen(xxx,xxx,xxx)
在 0.9.9.9 中是

#if defined(PROTOTYPES)
mutils_error mhash_keygen(keygenid algorithm, ....)
#else
mutils_error mhash_keygen();
#endif

(mutils_error是typedef的uint32)

而mcrypt的configure里头12114行用来测试的是

char mhash_keygen ();

即使把char改成 mutils_error 也还是不行。

求解。

回复内容:

想自己编译安装php的mcrypt扩展

# libmcrypt
tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/home/felix021/lamp/libmcrypt/
make
make install

# mhash
tar jxf mhash-0.9.9.9.tar.bz2
cd mhash-0.9.9.9
./configure --prefix=/home/felix021/lamp/mhash/
make
make install

# mcrypt
LD_LIBRARY_PATH=/home/felix021/lamp/libmcrypt/lib:/home/felix021/lamp/mhash/lib
./configure --prefix=/home/felix021/lamp/mcrypt/ --with-libmcrypt-prefix=/home/felix021/lamp/libmcrypt

configure不通过,提示:

checking for mhash_keygen in -lmhash... no
configure: error: "You need at least libmhash 0.8.15 to compile this program. http://mhash.sf.net/"

于是专门去找了mhash0.8.18和mhash0.8.15,依然是这个错误。

查了一下mhash_keygen这个函数,在0.8.15/8中是
int mhash_keygen(xxx,xxx,xxx)
在 0.9.9.9 中是

#if defined(PROTOTYPES)
mutils_error mhash_keygen(keygenid algorithm, ....)
#else
mutils_error mhash_keygen();
#endif

(mutils_error是typedef的uint32)

而mcrypt的configure里头12114行用来测试的是

char mhash_keygen ();

即使把char改成 mutils_error 也还是不行。

求解。

问题解决了,StackOverflow上面的大牛指出,在编译mcrypt之前需要在LDFLAGS中给出-L和-I

export LD_LIBRARY_PATH=/home/felix021/lamp/libmcrypt/lib:/home/felix021/lamp/mhash/lib
export LDFLAGS="-L/home/felix021/lamp/mhash/lib/ -I/home/felix021/lamp/mhash/include/"
export CFLAGS="-I/home/felix021/lamp/mhash/include/"
./configure --prefix=/home/felix021/lamp/mcrypt/ --with-libmcrypt-prefix=/home/felix021/lamp/libmcrypt

参见 http://stackoverflow.com/questions/63...

你新安装了动态链接库,在mcrypt configure之前执行一下ldconfig试试

直接用yum吧,直接编译源码的话,会有很多库的依赖,在configure的时候并没有处理好

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn