如何将目录添加到 ld 搜索路径以进行 ARM 交叉编译?
我正在尝试将 util-linux 配置为使用 CodeSourcery 中的 arm-none-linux-gnueabi 进行交叉编译。到目前为止,我唯一的问题是它找不到我编译的 ncurses 库。
如何将目录添加到 ld 搜索路径?我尝试添加到我的 LIBRARY_PATH 和 LD_LIBRARY_PATH 变量中,但两者都没有任何作用。我知道我可以将 -L 标志添加到 gcc 中,它将添加到链接器路径中,但是有没有办法在全局范围内执行此操作,以便我可以执行一次,而不必再次担心?
这是arm-none-linux-gnueabi-gcc -print-search-dirs | 的输出grep 库 | sed 's/:/\n/g':
libraries
=/tools/bin/../lib/gcc/arm-none-linux-gnueabi/4.6.1/
/tools/bin/../lib/gcc/
/tools/bin/../lib/gcc/arm-none-linux-gnueabi/4.6.1/../../../../arm-none-linux-gnueabi/lib/arm-none-linux-gnueabi/4.6.1/
/tools/bin/../lib/gcc/arm-none-linux-gnueabi/4.6.1/../../../../arm-none-linux-gnueabi/lib/
/tools/bin/../arm-none-linux-gnueabi/libc/lib/arm-none-linux-gnueabi/4.6.1/
/tools/bin/../arm-none-linux-gnueabi/libc/lib/
/tools/bin/../arm-none-linux-gnueabi/libc/usr/lib/arm-none-linux-gnueabi/4.6.1/
/tools/bin/../arm-none-linux-gnueabi/libc/usr/lib/
我想添加 /arm/usr/lib
和 /arm/usr/local/lib
到我的 ld 搜索路径。
如果您需要任何其他命令的输出,请询问!
编辑:我刚刚发现了 CFLAGS 环境变量——所有配置脚本/makefile 都遵守它吗?
谢谢你!
I am trying to configure util-linux to cross compile using arm-none-linux-gnueabi from CodeSourcery. My only problem so far is that it can't find my ncurses library which I compiled.
How can I add a directory to the ld search path? I've tried adding to my LIBRARY_PATH and LD_LIBRARY_PATH variables, but neither does anything. I know that I can add the -L flag to gcc and it will add to the linker path, but is there any way to do this globally, so that I can do it once, and not have to worry about it again?
Here is the output of arm-none-linux-gnueabi-gcc -print-search-dirs | grep libraries | sed 's/:/\n/g'
:
libraries
=/tools/bin/../lib/gcc/arm-none-linux-gnueabi/4.6.1/
/tools/bin/../lib/gcc/
/tools/bin/../lib/gcc/arm-none-linux-gnueabi/4.6.1/../../../../arm-none-linux-gnueabi/lib/arm-none-linux-gnueabi/4.6.1/
/tools/bin/../lib/gcc/arm-none-linux-gnueabi/4.6.1/../../../../arm-none-linux-gnueabi/lib/
/tools/bin/../arm-none-linux-gnueabi/libc/lib/arm-none-linux-gnueabi/4.6.1/
/tools/bin/../arm-none-linux-gnueabi/libc/lib/
/tools/bin/../arm-none-linux-gnueabi/libc/usr/lib/arm-none-linux-gnueabi/4.6.1/
/tools/bin/../arm-none-linux-gnueabi/libc/usr/lib/
I would like to add /arm/usr/lib
and /arm/usr/local/lib
to my ld search path.
If you need output from any other commands, just ask!
EDIT: I just found out about the CFLAGS environment variable--do all configure scripts/makefiles honor it?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您编译的 ncurses 库将链接到您正在交叉编译的 ARM 二进制文件,则不能使用 LD_LIBRARY_PATH! LD_LIBRARY_PATH 仅由当前运行时使用,编译器或链接器在构建应用程序时绝不会使用它。
CFLAGS 的使用取决于 Makefile 的创建者。即使将 CFLAGS 定义为环境变量,也不会自动使用它们。只有像 autoconf 工具这样的工具才能从环境中获取它们并自动使用它们。在 Makefile 中找到类似以下内容:
如果此片段存在,则 Makefile 使用 CFLAGS 变量。 LDFLAGS 是更适合用于链接时选项的环境变量。
If the ncurses library you compiled are going to be linked to the ARM binary you are cross-compiling you can not use LD_LIBRARY_PATH! LD_LIBRARY_PATH is only used by the current run-time and is in no way used by the compiler or linker when building your application.
The use of CFLAGS depends on creator of Makefile. CFLAGS are not automatically used even if they are defined as an environment variable. Only tools like the autoconf tools can pick them up from the environment and use them automagically. In the Makefiles find something like:
if this fragment exists then the Makefile uses the CFLAGS variable. LDFLAGS is the more appropriate environment variable to use for link-time options.