我正在尝试编译 crypto++ 库以运行 armhf 架构。我正在按照此 answer 中提供的方法进行操作.我调整了 setenv-embed.sh
以匹配我的系统配置。运行 的输出。 ./setenv-embed.sh
是
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
构建库时,我遇到了以下错误
/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.6
, libc_nonshared.a
和 ld-linux-armhf.so.3
我正在尝试为 Beaglebone 编译库,如果有帮助的话。
更新 1:
执行完git pull
后运行make -f GNUmakefile-cross system
的结果
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/
我从文件 GNUmakefile-cross 的第 68 行删除了 --sysroot
选项,所有编译和链接都正常。
但是,由于某些共享库版本不匹配,我无法在我的 BeagleBone Black 上运行该示例。但这对我来说不是真正的问题,因为在我的应用程序中我静态链接 crypto++,而不是动态链接。
关于c++ - 为 ARMHF 编译 Crypto++ 时出现链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31698241/