如何打印 ld(linker) 搜索路径 [英] How to print the ld(linker) search path

查看:23
本文介绍了如何打印 ld(linker) 搜索路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按搜索顺序打印ld 查找的搜索路径的方法是什么.

What is the way to print the search paths that in looked by ld in the order it searches.

推荐答案

您可以通过执行以下命令来做到这一点:

You can do this by executing the following command:

ld --verbose | grep SEARCH_DIR | tr -s ' ;' \012

gcc 将一些额外的 -L 路径传递给链接器,您可以使用以下命令列出这些路径:

gcc passes a few extra -L paths to the linker, which you can list with the following command:

gcc -print-search-dirs | sed '/^lib/b 1;d;:1;s,/[^/.][^/]*/../,/,;t 1;s,:[^=]*=,:;,;s,;,;  ,g' | tr ; \012

建议使用 ld.so.conf 和 ldconfig 的答案不正确,因为它们指的是运行时动态链接器搜索的路径(即每当程序执行时),这与 <搜索的路径不同strong>ld(即当程序被链接时).

The answers suggesting to use ld.so.conf and ldconfig are not correct because they refer to the paths searched by the runtime dynamic linker (i.e. whenever a program is executed), which is not the same as the path searched by ld (i.e. whenever a program is linked).

这篇关于如何打印 ld(linker) 搜索路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆