嵌入共享库的绝对路径

发布于 2024-07-28 14:59:57 字数 1289 浏览 17 评论 0原文

使用供应商提供的交叉编译工具链(显然是 OpenEmbedded 衍生品),我无法嵌入第三方(开源、内部编译)库的绝对路径。 使用以下 gcc 命令行:

arm-linux-gcc test_connect_send.o gprs_connect.o \
    /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libgprs_stuff.so \
    /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libpower_supply_stuff.so \
    /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libgsm_stuff.so \
    /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libtcp_stuff.so \
    /package/host/aspl.es/vortex-1.1.0/lib/libvortex-1.1.so \
    /package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0  -o test_connect_send

objdump 说:

Dynamic Section:
  NEEDED      /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libgprs_stuff.so
  NEEDED      /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libpower_supply_stuff.so
  NEEDED      /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libgsm_stuff.so
  NEEDED      /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libtcp_stuff.so
  NEEDED      libvortex-1.1.so.0
  NEEDED      libaxl.so.0
  NEEDED      libgcc_s.so.1
  NEEDED      libc.so.6

请注意我的供应商的库如何具有完整路径,而 aspl 则没有。 另外,请注意嵌入的名称与我在命令行中指定的名称有何不同。 我想知道为什么(谁扰乱了我的路径)以及如何解决它。

ps:我了解 RPATH,这不是我正在寻找的答案

Using a vendor provided cross-compiling toolchain (apparently an OpenEmbedded derivative), I'm unable to embed the absolute path to third-party (open source, compiled in house)libraries. With the following gcc command line:

arm-linux-gcc test_connect_send.o gprs_connect.o \
    /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libgprs_stuff.so \
    /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libpower_supply_stuff.so \
    /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libgsm_stuff.so \
    /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libtcp_stuff.so \
    /package/host/aspl.es/vortex-1.1.0/lib/libvortex-1.1.so \
    /package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0  -o test_connect_send

objdump says:

Dynamic Section:
  NEEDED      /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libgprs_stuff.so
  NEEDED      /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libpower_supply_stuff.so
  NEEDED      /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libgsm_stuff.so
  NEEDED      /package/host/myvendor.com/API-R-2.0.0/Release/Libraries/libtcp_stuff.so
  NEEDED      libvortex-1.1.so.0
  NEEDED      libaxl.so.0
  NEEDED      libgcc_s.so.1
  NEEDED      libc.so.6

Notice how my vendor's libraries do have their full path, while aspl's don't. Also, notice how the name embedded is different from the one I specified on the command line. I'd like to know why (who is messing with my paths), and how to solve it.

p.s.: I know about RPATH, that's not the answer I'm looking for

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

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

发布评论

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

评论(3

时光与爱终年不遇 2024-08-04 15:05:31

这是一个老问题,但我想无论如何我都会添加一个可能的答案。

仅根据您提供的信息,是否可能不包含 aspl 的完整路径名,因为您指定的 aspl 库是软链接? 例如,如果您列出一个很长的列表,例如 /package/host/aspl.es/vortex-1.1.0/lib/libvortex-1.1.so ,它将显示它是 libvortex-1.1.so.0 的链接(带有没有完整路径名)。

因此,如果您仍然想嵌入完整路径,那么您需要使用实际库的完整路径,而不是链接库。

This is an old question, but I thought I'd add a possible answer anyways.

Just based on the info you've given, could it be that the full path names aren't included for aspl because the aspl libraries you've specified are soft links? If you do a long list on, for instance, /package/host/aspl.es/vortex-1.1.0/lib/libvortex-1.1.so it will show that it's a link to libvortex-1.1.so.0 (with no full pathname).

So, if you still want to embedded the full path, then you need to use the full path to the actual library, not the linked library.

背叛残局 2024-08-04 15:04:04

arm-linux-gcc -print-file-name 没有显示任何令人惊讶的内容:

arm-linux-gcc -print-file-name=/package/host/aspl.es/axl-0.5.6/lib/libaxl.so。 0.0.0
/package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0.0.0
arm-linux-gcc -print-file-name=/package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0.0
/package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0.0
arm-linux-gcc -print-file-name=/package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0
/package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0
arm-linux-gcc -print-file-name=/package/host/aspl.es/axl-0.5.6/lib/libaxl.so
/package/host/aspl.es/axl-0.5.6/lib/libaxl.so

如果没有定义 LD_LIBRARY_PATH,则生成的二进制文件不会运行,也没有 DT_RPATH (尽管这肯定会有所帮助,建议?)

我不想要依赖 /etc/ld.so.conf 的正确设置,因此我想要到处都有绝对路径。

请注意,建议很可能指向第三方库的编译,目前这些库的编译方式为:

make distclean; LDFLAGS=-L/package/host/myvendor.com/arm9-linux-toolchain-2.1/prefix/arm-linux/lib CC=/package/host/myvendor.com/arm9-linux-toolchain-2.1/prefix/bin /arm-linux-gcc ~/wd/sources/contrib/axl/configure --prefix=/shared/syst/arm9-linux-abtrack/package/host/aspl.es/axl-0.5.6 --host=armv4tl -unknown-linux-gnu --disable-axl-knife --disable-axl-babel --disable-axl-log --disable-axl-test && 使

distclean; AXL_LIBS="-L/shared/syst/arm9-linux-abtrack/package/host/aspl.es/axl-0.5.6/lib/-laxl -lm" AXL_CFLAGS=-I/shared/syst/arm9-linux- abtrack/package/host/aspl.es/axl-0.5.6/include/axl CC=/package/host/myvendor.com/arm9-linux-toolchain-2.1/prefix/bin/arm-linux-gcc LDFLAGS=" -L/package/host/myvendor.com/arm9-linux-toolchain-2.1/prefix/arm-linux/lib" ~/wd/sources/contrib/vortex/configure --prefix=/shared/syst/arm9-linux -abtrack/package/host/aspl.es/vortex-1.1.0 --disable-http-support --disable-pull-support --disable-tunnel-support --disable-xml-rpc-support-gen --禁用-xml-rpc-support --禁用-sasl-support --disable-vortex-log --disable-vortex-client --host=armv4tl-unknown-linux-gnu && make 有

关于在编译库中嵌入 --prefix 的 autofoo 技巧吗?

arm-linux-gcc -print-file-name does not show anything suprising:

arm-linux-gcc -print-file-name=/package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0.0.0
/package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0.0.0
arm-linux-gcc -print-file-name=/package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0.0
/package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0.0
arm-linux-gcc -print-file-name=/package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0
/package/host/aspl.es/axl-0.5.6/lib/libaxl.so.0
arm-linux-gcc -print-file-name=/package/host/aspl.es/axl-0.5.6/lib/libaxl.so
/package/host/aspl.es/axl-0.5.6/lib/libaxl.so

The resulting binary does not run without LD_LIBRARY_PATH defined, nor does it have a DT_RPATH (although that might certainly help, suggestions?)

I don't want to rely on /etc/ld.so.conf being properly set, and thus I want absolute paths everywhere.

Note that suggestions might well point to the compilation of the third-party libraries, which as of now are compiled with:

make distclean; LDFLAGS=-L/package/host/myvendor.com/arm9-linux-toolchain-2.1/prefix/arm-linux/lib CC=/package/host/myvendor.com/arm9-linux-toolchain-2.1/prefix/bin/arm-linux-gcc ~/wd/sources/contrib/axl/configure --prefix=/shared/syst/arm9-linux-abtrack/package/host/aspl.es/axl-0.5.6 --host=armv4tl-unknown-linux-gnu --disable-axl-knife --disable-axl-babel --disable-axl-log --disable-axl-test && make

make distclean; AXL_LIBS="-L/shared/syst/arm9-linux-abtrack/package/host/aspl.es/axl-0.5.6/lib/ -laxl -lm" AXL_CFLAGS=-I/shared/syst/arm9-linux-abtrack/package/host/aspl.es/axl-0.5.6/include/axl CC=/package/host/myvendor.com/arm9-linux-toolchain-2.1/prefix/bin/arm-linux-gcc LDFLAGS="-L/package/host/myvendor.com/arm9-linux-toolchain-2.1/prefix/arm-linux/lib" ~/wd/sources/contrib/vortex/configure --prefix=/shared/syst/arm9-linux-abtrack/package/host/aspl.es/vortex-1.1.0 --disable-http-support --disable-pull-support --disable-tunnel-support --disable-xml-rpc-support-gen --disable-xml-rpc-support --disable-sasl-support --disable-vortex-log --disable-vortex-client --host=armv4tl-unknown-linux-gnu && make

Any autofoo tips for embedding --prefix in compiled libraries?

⊕婉儿 2024-08-04 15:02:59

我的猜测是供应商提供的库将 SONAME 设置为完整的安装路径。

My guess would be that the vendor supplied libs set the SONAME to the full installed path.

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