0

我正在尝试编译 这里是我的配置PCRE脚本CodeSourcery

#!/bin/bash

PROJECT_BASE=$(pwd);
PROJECT_REPOSITORY=$PROJECT_BASE/download
INSTALL_PREFIX=$PROJECT_BASE/compiled/armv5te

mkdir -p $INSTALL_PREFIX && mkdir -p $PROJECT_BASE/download && mkdir -p $PROJECT_BASE/build

export TOOL_PREFIX=${HOME}/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux
SYSROOT=$HOME/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/arm-none-linux-gnueabi/libc

export CC="${TOOL_PREFIX}/bin/arm-none-linux-gnueabi-gcc --sysroot=$SYSROOT"
export CXX="${TOOL_PREFIX}/bin/arm-none-linux-gnueabi-g++ --sysroot=$SYSROOT"

#CC="${TOOL_PREFIX}/bin/arm-none-linux-gnueabi-gcc"
#CXX="${TOOL_PREFIX}/bin/arm-none-linux-gnueabi-g++"

export AR="${TOOL_PREFIX}/bin/arm-none-linux-gnueabi-ar"
export RANLIB="${TOOL_PREFIX}/bin/arm-none-linux-gnueabi-ranlib"
export LD="${TOOL_PREFIX}/bin/arm-none-linux-gnueabi-ld"
export STRIP="${TOOL_PREFIX}/bin/arm-none-linux-gnueabi-strip"
export NM="${TOOL_PREFIX}/bin/arm-none-linux-gnueabi-nm"
export CCLD=$LD
export CHOST=arm-none-linux-gnueabi


PARENT_DIR=$(pwd);

cd $PROJECT_BASE/build && tar -xzvf $PROJECT_REPOSITORY/pcre-8.34.tar.gz && cd ./pcre-8.34

#LDFLAGS_DEP="-lc"

#CPPFLAGS="-I${INSTALL_PREFIX}/include"


# CFLAGS="-march=armv5t -marm -mlittle-endian -mglibc -static -I${INSTALL_PREFIX}/include"
LDFLAGS="-L${INSTALL_PREFIX}/lib"
./configure --prefix=$INSTALL_PREFIX/pcre --with-sysroot --target=arm-none-linux-gnueabi --host=x86_64 && make && make install;
   cd -;

   cd ${PARENT_DIR};

现在它已成功编译,但是当我尝试在 android 上执行该二进制文件时,我得到:

  ./pcregrep: not found

交叉编译 curl,openssl 时也有类似的问题,但是当我运行测试代码时

#include <stdio.h>

int main(){

   printf("Hell ya it works");
   return 0;
}

并使用以下选项编译

arm-none-linux-gnueabi-gcc hello.c -static -o hello.c

有用

4

2 回答 2

1

您正在尝试将 Linux 编译器与 Android 一起使用。它并没有完全损坏,因为 AndroidLinux,但 Android 并没有作为标准配备相同的库集。

可能可以安装 Linux 库(从适当的 CodeSourcery libc 目录),但这是一个棘手的过程,因为 Android 文件已经位于标准位置,因此必须以某种方式将它们安装到一侧,如果你不知道你在做什么它会陷入可怕的混乱。

最好的解决方案可能是使用完全静态的链接。也就是说,您可能仍然会发现 libcurl 不满意,因为即使是静态链接,它也要求它可以dlopen访问主机系统的 DNS 库,而我不知道 Android 喜欢这样做。

我建议您尝试使用专门构建的 Android 工具链(我相信 Linaro 会这样做),该工具链旨在使用 Android 的“仿生”C 库,而不是 GNU/Linux 的“Glibc”。

于 2014-03-10T09:50:17.163 回答
0

它在代码源工具链的 libc 和目标 rootfs 中的 libc 之间不匹配。宿主机交叉编译器中的 libc 和部署在设备上的 rootfs 不同

arm-none-linux-gnueabi-gcc hello.c -static -o hello.c

它有效`

由于您是静态编译的,因此这有效,因此无需将 libc 复制到此处的目标。

但是pcre你是动态构建的。check file ./pcregrep如果它的动态链接然后

一种最简单的方法是静态编译为你好,例如。并在你的目标上运行。

否则将 libc 从工具链复制到目标并将其导出然后它将起作用

于 2014-03-09T10:13:36.803 回答