简体   繁体   English

嵌入共享库的绝对路径

[英]embedding absolute path for shared libraries

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. 使用供应商提供的交叉编译工具链(显然是OpenEmbedded衍生产品),我无法将绝对路径嵌入到第三方(开源,内部编译)库中。 With the following gcc command line: 使用以下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 says: 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

Notice how my vendor's libraries do have their full path, while aspl's don't. 请注意我的供应商的库如何拥有完整的路径,而aspl则没有。 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. 我想知道为什么(谁在弄乱我的路径),以及如何解决它。

ps: I know about RPATH, that's not the answer I'm looking for ps:我知道RPATH,这不是我正在寻找的答案

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

arm-linux-gcc -print-file-name does not show anything suprising: 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 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?) 如果没有定义LD_LIBRARY_PATH,生成的二进制文件不会运行,也不会有DT_RPATH(虽然这可能肯定有帮助,建议?)

I don't want to rely on /etc/ld.so.conf being properly set, and thus I want absolute paths everywhere. 我不想依赖/etc/ld.so.conf正确设置,因此我想要到处都是绝对路径。

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 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 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? 在编译库中嵌入--prefix的任何autofoo技巧?

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? 根据您提供的信息,可能是aspl不包含完整路径名,因为您指定的aspl库是软链接吗? 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). 如果你做了一个很长的列表,例如/package/host/aspl.es/vortex-1.1.0/lib/libvortex-1.1.so它会显示它是libvortex-1.1.so.0的链接(带有没有完整的路径名)。

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. 因此,如果您仍希望嵌入完整路径,则需要使用实际库的完整路径,而不是链接库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM