2011年(16)
分类: LINUX
2011-08-23 14:38:46
var $tag='gmp'; var $tag_code='516b3a53d3725adede250839f081be99'; var $r_quote_bligid='4df77d3001000ap9'; var $worldcup='0'; var $worldcupball='0'; 标签: gmp |
The main target applications for GMP are cryptography applications and research, Internet security applications, algebra systems, computational algebra research, etc.
GMP is carefully designed to be as fast as possible, both for small operands and for huge operands. The speed is achieved by using fullwords as the basic arithmetic type, by using fast algorithms, with highly optimized assembly code for the most common inner loops for a lot of CPUs, and by a general emphasis on speed.
GMP is faster than any other bignum library. The advantage for GMP increases with the operand sizes for many operations, since GMP uses asymptotically faster algorithms.
The first GMP release was made in 1991. It is continually developed and maintained, with a new release about once a year.
GMP is distributed under the GNU GPL. This license makes the library free to use, share, and improve, and allows you to pass on the result. The license gives freedoms, but also sets firm restrictions on the use with non-free programs.
如果你在编译时出现
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/.../arm-linux/bin/ld: cannot find -lgmp
collect2: ld returned 1 exit status
就说明你的gmp库有问题了,去下个吧,一搜就有很多,比如然后
tar zxvf gmp-3.1.1.tar.gz
cd gmp-3.1.1
./configure
make
make install
如果用在交叉编译,情况还复杂一些,上边的那个出错例子就是在交叉编译openswan用户程序的时候出现的,这个时候必须交叉编译gmp库(你可以看到在usr/local/arm/3.4.1/arm-linux/lib下有很多这样的库)。在./configure后面加参数来改,可以看man。
改宿主机和目标机
./configure --build=i386-pc-none --host=arm-linux
改编译器
./configure CC="/usr/local/arm/3.4.1/bin/arm-linux-gcc" CPP="/usr/local/arm/3.4.1/bin/arm-linux-gcc -E"
下面是改好后的makefile片断
......
build_alias = i386-pc-none
build_triplet = i386-pc-none
host_alias = arm-linux
host_triplet = arm-unknown-linux-gnu
target_alias = arm-linux
target_triplet = arm-unknown-linux-gnu
AMDEP =
AMTAR = ${SHELL} /opt/vpn/services/gmp-3.1.1/missing --run tar
AR = ar
AS = @AS@
AWK = gawk
CALLING_CONVENTIONS_OBJS =
CC = /usr/local/arm/3.4.1/bin/arm-linux-gcc
CCAS = /usr/local/arm/3.4.1/bin/arm-linux-gcc -c
CPP = /usr/local/arm/3.4.1/bin/arm-linux-gcc -E
CXX = @CXX@
CXXCPP = @CXXCPP@
......
然后再
make
make install
在/usr/local/lib下生成libgmp.a libgmp.la libgmp.so.3.1.1,把它们考到/usr/local/arm/3.4.1/arm-linux/lib下就可以啦。
交叉编译器是包含gmp库的,但用于加密和大数运算的gmp库更新很快,所以经常遇到在安装软件或编译源码时gmp库不匹配的问题。这个时候,更新gmp库就用到啦。
本人所用的gmp库版本为4.3.1,交叉编译时指定
./configure --host=arm-none-linux CC=arm-none-linux-gcc
最后make生成的库文件拷贝至arm 的根文件系统 /lib/下即可。