素材牛VIP会员
编译mcrypt出错,mhash怎么都对不上(已解决)
 go***le  分类:PHP代码  人气:1069  回帖:6  发布于6年前 收藏

想自己编译安装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 也还是不行。

求解。

讨论这个帖子(6)垃圾回帖将一律封号处理……

Lv4 码徒
12***mo UI设计师 6年前#1

重新烙个印。最好在安装libmcrypt和mhash就指定安装路径。这样在后面设置LD_LIBRARY_PATH 、LDFLAGS和CFLAGS就不会找错了。

Lv6 码匠
天***月 职业无 6年前#2
export LDFLAGS="-L/usr/local/mhash/lib"(LDFLAGS是告诉链接器从哪里寻找库文件)
export CFLAGS="-I/usr/local/mhash/include"(安装一个包时会在安装路径下建立一个include目录,当安装过程中出现问题时,试着把以前安装的包的include目录加入到该变量中来)

这样写也可以
把2个路径都写在LDFLAGS变量里面也能读出来,不过分开写对于初学者更容易理解

Lv4 码徒
想***儿 技术总监 6年前#3

问题解决了,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...

Lv5 码农
潇***a PHP开发工程师 6年前#4

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

Lv3 码奴
郑***y 其它 6年前#5

僵尸?
问题?

Lv3 码奴
ze***91 站长 6年前#6

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

 文明上网,理性发言!   😉 阿里云幸运券,戳我领取