为 ARMHF 编译 Crypto++ 时出现链接错误 [英] Linking error when compiling Crypto++ for ARMHF

查看:32
本文介绍了为 ARMHF 编译 Crypto++ 时出现链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译 crypto++ 库以运行 armhf 架构.我正在遵循此 answer 中提供的方法.我调整了 setenv-embed.sh 以匹配我的系统配置.运行 的输出../setenv-embed.sh

I'm trying to compile the crypto++ library to run for the armhf architecture. I'm following the method provided in this answer. I tweaked the setenv-embed.sh to match my system's configuration. The output of running . ./setenv-embed.sh is

CPP: /usr/bin/arm-linux-gnueabihf-cpp 
CXX: /usr/bin/arm-linux-gnueabihf-g++
AR: /usr/bin/arm-linux-gnueabihf-ar
LD: /usr/bin/arm-linux-gnueabihf-ld
RANLIB: /usr/bin/arm-linux-gnueabihf-gcc-ranlib-4.8

ARM_EMBEDDED_TOOLCHAIN: /usr/bin
ARM_EMBEDDED_CXX_HEADERS: /usr/arm-linux-gnueabihf/include/c++/4.8.2
ARM_EMBEDDED_FLAGS: -march=armv7-a mfloat-abi=hard -mfpu=neon -I/usr/arm-linux-gnueabihf/include/c++/4.8.2 -I/usr/arm-linux-gnueabihf/include/c++/4.8.2/arm-linux-gnueabihf 
ARM_EMBEDDED_SYSROOT: /usr/arm-linux-gnueabihf

表示已找到正确的编译器.但是,当我使用 make 构建库时,我遇到了以下错误

which indicates that the correct compilers have been found. However, when I build the library using make I run into the following error

/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/‌​ld: cannot find /usr/arm-linux-gnueabihf/lib/libc.so.6 inside /usr/arm-linux-gnueabihf
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/‌​ld: cannot find /usr/arm-linux-gnueabihf/lib/libc_nonshared.a inside /usr/arm-linux-gnueabihf        
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/‌​ld: cannot find /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 inside /usr/arm-linux-gnueabihf

但是当我打开位置/usr/arm-linux-gnueabihf/lib时,我可以找到上面提到的所有三个错误文件,即libc.so.6libc_nonshared.ald-linux-armhf.so.3

But when I open the location /usr/arm-linux-gnueabihf/lib I can find all the three error files mentioned above ie libc.so.6, libc_nonshared.a and ld-linux-armhf.so.3

如果有帮助的话,我正在尝试为 Beaglebone 编译库.

I'm trying to compile the library for Beaglebone, if that helps.

更新 1:

重新git pull

hassan@hassan-Inspiron-7537:~/cryptopp-armhf$ make -f GNUmakefile-cross system
CXX: /usr/bin/arm-linux-gnueabihf-g++
CXXFLAGS: -DNDEBUG -g2 -Os -Wall -Wextra -DCRYPTOPP_DISABLE_ASM -march=armv7-a -mfloat-abi=hard -mfpu=neon -mthumb -I/usr/arm-linux-gnueabihf/include/c++/4.8.2 -I/usr/arm-linux-gnueabihf/include/c++/4.8.2/arm-linux-gnueabihf --sysroot=/usr/arm-linux-gnueabihf -Wno-type-limits -Wno-unknown-pragmas
LDLIBS: 
GCC_COMPILER: 1
CLANG_COMPILER: 0
INTEL_COMPILER: 0
UNALIGNED_ACCESS: 
UNAME: Linux hassan-Inspiron-7537 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
MACHINE: 
SYSTEM: 
RELEASE: 
make: Nothing to be done for `system'.

推荐答案

问题很简单.它位于 --sysroot 选项中.此选项的值是 /usr/arm-linux-gnueabihf/ 并且它被链接器使用并且生成的库文件夹变为/usr/arm-linux-gnueabihf/usr/arm-linux-gnueabihf/lib/

The problem is simple. It is in the --sysroot option. The value of this option is /usr/arm-linux-gnueabihf/ and it is used by the linker and the resulting library folder becomes /usr/arm-linux-gnueabihf/usr/arm-linux-gnueabihf/lib/

我从文件 GNUmakefile-cross 的第 68 行中删除了 --sysroot 选项,所有编译和链接都正常.

I removed the --sysroot option from line 68 in the file GNUmakefile-cross and everything compiled and linked OK.

但是,由于某些共享库版本不匹配,我无法在我的 BeagleBone Black 上运行该示例.但这对我来说并不是一个真正的问题,因为在我的应用程序中,我是静态链接 crypto++,而不是动态链接.

However, I couldn't run the example on my BeagleBone Black because of mismatch of some shared libraries versions. But this wasn't a real problem for me, because in my application I link crypto++ statically, not dynamically.

这篇关于为 ARMHF 编译 Crypto++ 时出现链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆