简体   繁体   English

为什么libnettle 2.7.1的.configure即使存在-lgmp也找不到?

[英]Why can't .configure for libnettle 2.7.1 find -lgmp even though it is there?

I'm trying to compile gnutls for arm on my x86 machine (Ubuntu 11.04 under VirtualBox). 我正在尝试在x86机器(VirtualBox下的Ubuntu 11.04)上为arm编译gnutls。 Right now I'm stuck compiling libnettle. 现在,我被困在编译libnettle。 ./configure script can't find -lgmp and produces nettle without public key cryptography (no libhogweed ) which I need. ./configure脚本在没有我需要的公共密钥密码术(没有libhogweed )的情况下找不到-lgmp并产生荨麻。 Message in config.log is as follows: config.log中的消息如下:

For x86: 对于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

And for ARM: 对于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

Those libraries are there: 这些库在那里:

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

And they work outside of ./configure : 它们在./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

Here is my build environment: 这是我的构建环境:

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

And my build script: 而我的构建脚本:

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

请尝试以下命令,它将起作用。给您的手臂构建的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

As in your case its trying to finding to link gmp. 如您的情况,它试图找到链接gmp。 so LDFLAGS will link your library files. 因此LDFLAGS将链接您的库文件。

To know more about how to compile you can try like below command.It shows some light on your configuartion. 要了解更多有关如何编译的信息,您可以尝试使用以下命令,它显示了一些配置信息。

./configure --help

here you can see various option for compilation. 在这里,您可以看到各种编译选项。

Fine tuning of the installation directories:

This gives fine tuning of your package. 这可以对您的程序包进行微调。

System types:

Under this option it will show for which machine or architecture you can build and compile. 在此选项下,它将显示您可以针对哪些机器或体系结构进行构建和编译。

Some influential environment variables:

this section gives complete control over your Flags for compiling and building your package 本节完全控制您的Flags,以编译和构建程序包

So I thought I would provide you with the script that finally did it for me (it is based on vinay hunachyal'a answer). 所以我想我会为您提供最终为我完成的脚本(它基于vinay hunachyal'a的答案)。 It builds gnutls with all dependencies (two mandatory ones + zlib) for x86 and ARM (i.MX25). 它为x86和ARM(i.MX25)构建具有所有依赖项(两个强制性依赖项+ zlib)的gnutls。

Mind you, that it does no error checking so it is unsafe to execute out of the box. 请注意,它不会进行错误检查,因此立即执行是不安全的。 But it is good for reference purposes. 但这仅供参考。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM