为什么不能.configure为libnettle 2.7.1找-lgmp,即使它存在?

时间:2013-07-24 07:00:02

标签: linux build compilation

我正在尝试在我的x86机器上编译gnutls for arm(在VirtualBox下的Ubuntu 11.04)。现在我被困在编译libnettle。 ./ configure 脚本找不到-lgmp,并且在没有我需要的公钥加密(没有 libhogweed )的情况下生成nettle。 config.log 中的消息如下:

对于x86:

configure:6976: checking for __gmpz_getlimbn in -lgmp
configure:7001: gcc -o conftest -L"/home/xena/gnutls/out/x86/lib/"   conftest.c -lgmp   >&5
/usr/bin/ld: cannot find -lgmp
collect2: ld returned 1 exit status
configure:7001: $? = 1

对于ARM:

configure:6976: checking for __gmpz_getlimbn in -lgmp
configure:7001: arm-none-linux-gnueabi-gcc -o conftest -L"/home/xena/gnutls/out/arm/lib/" -mcpu=arm926ej-s -mthumb   conftest.c -lgmp   >&5
/usr/local/codesourcery/bin/../lib/gcc/arm-none-linux-gnueabi/4.7.3/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status
configure:7001: $? = 1

那些图书馆在那里:

xena@xena-VirtualBox:~/gnutls$ ls /home/xena/gnutls/out/x86/lib/ | grep libgmp
libgmp.a
libgmp.la
libgmp.so
libgmp.so.10
libgmp.so.10.1.2
xena@xena-VirtualBox:~/gnutls$ ls /home/xena/gnutls/out/arm/lib/ | grep libgmp
libgmp.a
libgmp.la
libgmp.so
libgmp.so.10
libgmp.so.10.1.2

他们在 ./ configure 之外工作:

xena@xena-VirtualBox:~/gnutls$ gedit conftest.c
xena@xena-VirtualBox:~/gnutls$ gcc -o conftest -L"/home/xena/gnutls/out/x86/lib/"   conftest.c -lgmp
xena@xena-VirtualBox:~/gnutls$ ls | grep conftest
conftest
conftest.c
xena@xena-VirtualBox:~/gnutls$ rm conftest
xena@xena-VirtualBox:~/gnutls$ gedit conftest.c
xena@xena-VirtualBox:~/gnutls$ arm-none-linux-gnueabi-gcc -o conftest -L"/home/xena/gnutls/out/arm/lib/" -mcpu=arm926ej-s -mthumb   conftest.c -lgmp
xena@xena-VirtualBox:~/gnutls$ ls | grep conftest
conftest
conftest.c
xena@xena-VirtualBox:~/gnutls$ rm conftest

这是我的构建环境:

xena@xena-VirtualBox:~/gnutls$ pwd
/home/xena/gnutls
xena@xena-VirtualBox:~/gnutls$ ls
build.sh  clean.sh  gmp-5.1.2.tar.xz  gmp-help.txt  gnutls-3.2.2.tar.xz  gnutls-help.txt  nettle-2.7.1.tar.gz  nettle-help.txt

我的构建脚本:

ROOT=/home/xena/gnutls

mkdir -p $ROOT/out

tar -xf gmp-5.1.2.tar.xz; cd gmp-5.1.2/
./configure --prefix=$ROOT/out/x86 && make && make install
cd ..; mv gmp-5.1.2 gmp-5.1.2.x86

tar -xf gmp-5.1.2.tar.xz; cd gmp-5.1.2/
./configure --prefix=$ROOT/out/arm --host=arm-none-linux-gnueabi CFLAGS="-mcpu=arm926ej-s -mthumb" && make && make install
cd ..; mv gmp-5.1.2 gmp-5.1.2.arm



tar -xf nettle-2.7.1.tar.gz; cd nettle-2.7.1/
./configure --prefix=$ROOT/out/x86 --disable-openssl --enable-shared CFLAGS="-L\"$ROOT/out/x86/lib/\"" && make && make install
cd ..; mv nettle-2.7.1 nettle-2.7.1.x86

tar -xf nettle-2.7.1.tar.gz; cd nettle-2.7.1/
./configure --prefix=$ROOT/out/arm --disable-openssl --enable-shared --host=arm-none-linux-gnueabi CFLAGS="-L\"$ROOT/out/arm/lib/\" -mcpu=arm926ej-s -mthumb" && make && make install
cd ..; mv nettle-2.7.1 nettle-2.7.1.arm



#tar -xf gnutls-3.2.2.tar.xz; cd gnutls-3.2.2/
#./configure --prefix=$ROOT/gnutls-out/x86 --enable-threads=posix --with-sysroot=$ROOT/out/x86 && make && make install
#cd ..; mv gnutls-3.2.2 gnutls-3.2.2.x86

#tar -xf gnutls-3.2.2.tar.xz; cd gnutls-3.2.2/
#./configure --prefix=$ROOT/gnutls-out/arm --enable-threads=posix --with-sysroot=$ROOT/out/arm --host=arm-none-linux-gnueabi CFLAGS="-mcpu=arm926ej-s -mthumb" && make && make install
#cd ..; mv gnutls-3.2.2 gnutls-3.2.2.arm

3 个答案:

答案 0 :(得分:0)

尝试以下命令它将工作。给你的手臂构建gmp库和包含文件的正确路径。

tar -xf nettle-2.7.1.tar.gz; cd nettle-2.7.1/

CFLAGS=-L/$ROOT/out/arm CPPFLAGS=-I/$ROOT/out/arm/include LDFLAGS=-L$ROOT/out/arm/lib ./configure --prefix=$ROOT/out/arm --disable-openssl --enable-shared --host=arm-none-linux-gnueabi

答案 1 :(得分:0)

在你的情况下,它试图找到链接gmp。所以LDFLAGS会链接你的库文件。

要了解有关如何编译的更多信息,可以尝试使用以下命令。它显示了您的配置的一些亮点。

./configure --help

在这里你可以看到各种编译选项。

Fine tuning of the installation directories:

这可以对您的包进行微调。

System types:

在此选项下,它将显示您可以构建和编译的机器或体系结构。

Some influential environment variables:

本节完全控制您的Flags以编译和构建包

答案 2 :(得分:0)

所以我想我会为你提供最终为我做的剧本(它基于vinay hunachyal'a答案)。它为x86和ARM(i.MX25)构建了具有所有依赖关系(两个强制性的+ zlib)的gnutls。

请注意,它没有错误检查,因此开箱即用是不安全的。但它有助于参考目的。

echo "This file too unflexible / uncaring about return codes to be run confidently. Use it for reference purposes only!"
exit 1;

ROOT=/home/xena/gnutls

mkdir -p $ROOT/out

tar -xf gmp-5.1.2.tar.xz; cd gmp-5.1.2/
./configure --prefix=$ROOT/gmp-out/x86 --enable-cxx && make && make install
cd ..; mv gmp-5.1.2 gmp-5.1.2.x86

tar -xf gmp-5.1.2.tar.xz; cd gmp-5.1.2/
CFLAGS="-mcpu=arm926ej-s -mthumb" ./configure --prefix=$ROOT/gmp-out/arm --host=arm-none-linux-gnueabi && make && make install
cd ..; mv gmp-5.1.2 gmp-5.1.2.arm

cp -R $ROOT/gmp-out/* $ROOT/out



tar -xf zlib-1.2.8.tar.xz; cd zlib-1.2.8/
./configure --prefix=$ROOT/zlib-out/x86 && make && make install
cd ..; mv zlib-1.2.8 zlib-1.2.8.x86

tar -xf zlib-1.2.8.tar.xz; cd zlib-1.2.8/
CC="arm-none-linux-gnueabi-gcc" CFLAGS="-mcpu=arm926ej-s -mthumb" ./configure --prefix=$ROOT/zlib-out/arm && make && make install
cd ..; mv zlib-1.2.8 zlib-1.2.8.arm

cp -R $ROOT/zlib-out/* $ROOT/out



tar -xf nettle-2.7.1.tar.gz; cd nettle-2.7.1/
CFLAGS="-L$ROOT/out/x86 -I$ROOT/out/x86/include" CPPFLAGS=-I$ROOT/out/x86/include LDFLAGS=-L$ROOT/out/x86/lib LD_LIBRARY_PATH="$ROOT/out/x86/lib:$LD_LIBRARY_PATH" ./configure --prefix=$ROOT/nettle-out/x86 --disable-openssl --enable-shared                               && make && make install
cd ..; mv nettle-2.7.1 nettle-2.7.1.x86

tar -xf nettle-2.7.1.tar.gz; cd nettle-2.7.1/
CFLAGS="-L$ROOT/out/arm -mcpu=arm926ej-s -mthumb" CPPFLAGS=-I$ROOT/out/arm/include LDFLAGS=-L$ROOT/out/arm/lib ./configure --prefix=$ROOT/nettle-out/arm --disable-openssl --enable-shared --host=arm-none-linux-gnueabi && make && make install
cd ..; mv nettle-2.7.1 nettle-2.7.1.arm

cp -R $ROOT/nettle-out/* $ROOT/out



tar -xf gnutls-3.2.2.tar.xz; cd gnutls-3.2.2/
CFLAGS="-L$ROOT/out/x86 -I$ROOT/out/x86/include"  NETTLE_CFLAGS="-I$ROOT/out/x86/include/nettle" NETTLE_LIBS="-lnettle" HOGWEED_CFLAGS="-I$ROOT/out/x86/include/nettle" HOGWEED_LIBS="-lhogweed" CPPFLAGS=-I$ROOT/out/x86/include LDFLAGS=-L$ROOT/out/x86/lib LD_LIBRARY_PATH="$ROOT/out/x86/lib:$LD_LIBRARY_PATH" ./configure --with-libz-prefix="$ROOT/out/x86/" --prefix=$ROOT/gnutls-out/x86 --enable-threads=posix --with-sysroot=$ROOT/out/x86 && make
make install # "make" fails because my system lacks makeinfo from texinfo package, but software builds correctly so I just ignore that error
cd ..; mv gnutls-3.2.2 gnutls-3.2.2.x86

tar -xf gnutls-3.2.2.tar.xz; cd gnutls-3.2.2/
CFLAGS="-L$ROOT/out/arm -mcpu=arm926ej-s -mthumb" NETTLE_CFLAGS="-I$ROOT/out/arm/include/nettle" NETTLE_LIBS="-lnettle" HOGWEED_CFLAGS="-I$ROOT/out/arm/include/nettle" HOGWEED_LIBS="-lhogweed" CPPFLAGS=-I$ROOT/out/arm/include LDFLAGS=-L$ROOT/out/arm/lib                                                      ./configure --with-libz-prefix="$ROOT/out/arm/" --prefix=$ROOT/gnutls-out/arm --enable-threads=posix --with-sysroot=$ROOT/out/arm --host=arm-none-linux-gnueabi && make
make install # same as above
cd ..; mv gnutls-3.2.2 gnutls-3.2.2.arm

cp -R $ROOT/gnutls-out/* $ROOT/out