android 工具链缺少 crtbegin_so.o (自定义构建)
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
适用于 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:配置使用的标志:
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:
我发现将
--sysroot=$(SYSROOT)
添加到编译器选项可以修复错误:我的 makefile 中没有此类文件或目录...
注意:这假设已运行 setenv-android.sh 来设置环境
<代码>$. ./setenv-android.sh
I have found that adding
--sysroot=$(SYSROOT)
to the compiler options fixes the error:from my makefile...
Note: this assumes that the setenv-android.sh has been run to setup the environment
$. ./setenv-android.sh
就我而言,sysroot 路径中缺少引号。
当我更改
为
项目时,编译并链接成功。
In my case quotes were missing from sysroot path.
When I changed
to
the project was compiled and linked successfully.
我在两个不同的情况下遇到了同样的问题:
boost
期间android-cmake
项目。一旦我切换到
独立工具链
问题就消失了,这里是准备独立工具链
Boost特定
的命令示例,您需要指定
--sysroot
在您的jam
中多次I faced with the same issue in two separate cases:
boost
for androidandroid-cmake
project.Once I have switched to
standalone toolchain
issue gone, here is example of command which preparestandalone toolchain
Boost specific
for boost you need specify
--sysroot
several times in yourjam