android 工具链缺少 crtbegin_so.o (自定义构建)

发布于 2024-11-26 23:36:05 字数 516 浏览 3 评论 0原文

我使用 android build-gcc.sh 脚本将 gdc 与 gcc 一起编译,并在 build/core/definitions.mk 中包含了一个新的存根,以在构建过程中处理 D 语言文件。我知道此时编译一切正常,但我的问题是链接:

当我构建项目时,我收到此错误:

ld: crtbegin_so.o: No such file: No such file or directory

对于常规仅 c 项目也是如此。现在,我在构建目录中快速查找,发现文件 (crtbegin_so.o) 确实存在于我编译 gcc 时指定的 sysroot 中(或者更确切地说,当构建 build-gcc.sh 时)它)。

  • 我可以寻找哪些内容来找到此问题的解决方案?

  • 在本地复制文件并直接链接到它们是否是一个不错的解决方案 临时?

  • 为什么 ld(或collect2)会尝试在 gdc(D 语言)链接中包含这些内容?

I have compiled gdc together with gcc using the android build-gcc.sh script, and have included a new stub in build/core/definitions.mk to deal with D language files as a part of the build process. I know things are compiling OK at this point, but my problem is linking:

When I build a project, I get this error:

ld: crtbegin_so.o: No such file: No such file or directory

This is true for regular c-only projects as well. Now I ran a quick find in my build directory, and found that the file (crtbegin_so.o) does exist within the sysroot I specified when I compiled gcc (or rather, when build-gcc.sh built it).

  • What are some things I could look for to find a solution to this problem?

  • Would copying the files locally and linking directly to them be a decent solution in the
    interim?

  • Why would ld (or collect2) be trying to include these for a gdc (D Language) linkage?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

满意归宿 2024-12-03 23:36:05

适用于 Linux 的 NDK r7c 上也会出现此问题。

我发现工具链忽略了平台位置($NDK_ROOT/platforms/android-8/arch-arm/usr/lib/)并在工具链路径中搜索它,这是不正确的。

但是,由于工具链也会在当前目录中搜索文件,因此一种解决方案是将正确的平台 crtbegin_so.o 和 crtend_so.o 符号链接到源目录中:

cd src && ln -s NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtbegin_so.a

cd src && ln -s NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtend_so.a

因此你的第二点应该解决(你可以在其中进行符号链接,而不是副本)

注意1:假设正在使用 NDK 为 API8 (Android 2.2) 编译代码。请根据您的要求将路径更改为正确的路径。

注2:配置使用的标志:

./configure \
--host=arm-linux-androideabi \
CC=arm-linux-androideabi-gcc \
CPPFLAGS="-I$NDK_ROOT/platforms/android-8/arch-arm/usr/include/" \
CFLAGS="-nostdlib" \
LDFLAGS="-Wl,-rpath-link=$NDK_ROOT/platforms/android-8/arch-arm/usr/lib/ -L$NDK_ROOT/platforms/android-8/arch-arm/usr/lib/" \
LIBS="-lc"

The issue arises on NDK r7c for linux as well.

I found that the toolchain ignores the platform location ($NDK_ROOT/platforms/android-8/arch-arm/usr/lib/) and searches for it in the toolchain path, which is incorrect.

However, as the toolchain also searches for the file in the current directory, one solution is to symlink the correct platform crtbegin_so.o and crtend_so.o into the source directory:

cd src && ln -s NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtbegin_so.a

cd src && ln -s NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtend_so.a

Thus your second point should work out (where you can do a symlink, instead of a copy)

NOTE 1:This assumes that the code is being compiled for API8 (Android 2.2) using the NDK. Please alter the path to the correct path as per your requirement.

NOTE 2:Configure flags used:

./configure \
--host=arm-linux-androideabi \
CC=arm-linux-androideabi-gcc \
CPPFLAGS="-I$NDK_ROOT/platforms/android-8/arch-arm/usr/include/" \
CFLAGS="-nostdlib" \
LDFLAGS="-Wl,-rpath-link=$NDK_ROOT/platforms/android-8/arch-arm/usr/lib/ -L$NDK_ROOT/platforms/android-8/arch-arm/usr/lib/" \
LIBS="-lc"
夜未央樱花落 2024-12-03 23:36:05

我发现将 --sysroot=$(SYSROOT) 添加到编译器选项可以修复错误:

无法打开crtbegin_so.o:没有这样的文件或目录

我的 makefile 中没有此类文件或目录...

CC= $(CROSS_COMPILE)gcc -fvisibility-hidded $(INC) $(LIB) -shared

注意:这假设已运行 setenv-android.sh 来设置环境
<代码>$. ./setenv-android.sh

I have found that adding --sysroot=$(SYSROOT) to the compiler options fixes the error:

cannot open crtbegin_so.o: No such file or directory

from my makefile...

CC= $(CROSS_COMPILE)gcc -fvisibility-hidded $(INC) $(LIB) -shared

Note: this assumes that the setenv-android.sh has been run to setup the environment
$. ./setenv-android.sh

遗失的美好 2024-12-03 23:36:05

就我而言,sysroot 路径中缺少引号。
当我更改

--sysroot=${ANDROID_NDK}\platforms\android-17\arch-arm

--sysroot="${ANDROID_NDK}\platforms\android-17\arch-arm" 

项目时,编译并链接成功。

In my case quotes were missing from sysroot path.
When I changed

--sysroot=${ANDROID_NDK}\platforms\android-17\arch-arm

to

--sysroot="${ANDROID_NDK}\platforms\android-17\arch-arm" 

the project was compiled and linked successfully.

凡尘雨 2024-12-03 23:36:05

我在两个不同的情况下遇到了同样的问题:

  1. 为 android 构建 boost 期间
  2. 在使用期间 android-cmake 项目。

一旦我切换到独立工具链问题就消失了,这里是准备独立工具链

$NDK_ROOT/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=android-toolchain --ndk-dir=$NDK_ROOT --system=darwin-x86_64 --toolchain=arm-linux-androideabi-4.9

Boost特定

的命令示例,您需要指定--sysroot 在您的 jam 中多次

<compileflags>--sysroot=$NDK_ROOT/platforms/android-9/arch-arm
<linkflags>--sysroot=$NDK_ROOT/platforms/android-9/arch-arm

I faced with the same issue in two separate cases:

  1. during building boost for android
  2. during using android-cmake project.

Once I have switched to standalone toolchain issue gone, here is example of command which prepare standalone toolchain

$NDK_ROOT/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=android-toolchain --ndk-dir=$NDK_ROOT --system=darwin-x86_64 --toolchain=arm-linux-androideabi-4.9

Boost specific

for boost you need specify --sysroot several times in your jam

<compileflags>--sysroot=$NDK_ROOT/platforms/android-9/arch-arm
<linkflags>--sysroot=$NDK_ROOT/platforms/android-9/arch-arm
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文