0

我正在尝试在我的 x86 机器(VirtualBox 下的 Ubuntu 11.04)上为 arm 编译 gnutls。现在我一直在编译 libnettle。./configure脚本找不到 -lgmp 并在没有我需要的公钥加密(没有libhogweed )的情况下生成荨麻。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
4

3 回答 3

1

试试下面的命令,它会起作用。为你的 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

于 2013-07-24T09:11:29.540 回答
0

就像你的情况一样,它试图找到链接 gmp。所以 LDFLAGS 将链接您的库文件。

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

./configure --help

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

Fine tuning of the installation directories:

这可以微调您的包。

System types:

在此选项下,它将显示您可以为哪台机器或架构构建和编译。

Some influential environment variables:

本节提供对编译和构建包的标志的完全控制

于 2013-07-24T10:22:16.327 回答
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
于 2013-07-25T05:08:20.820 回答