Scons 将磁盘名称前缀添加到 NFS LIBPATH

发布于 2024-08-06 19:07:56 字数 313 浏览 7 评论 0原文

你好,我正在用 Scons 构建环境。 对于 Windows 平台(链接)链接器获取 Scons 设置 我的共享库路径的前缀 - 磁盘名称

我在 NFS 上有库:

libs='\\\\share\\lib\\lib'

在 scons 中我有:

env.Append(LIBPATH = [libs]) 

结果是链接器调用如下内容:

/LIBPATH:D:\share\lib\lib

Hi I'm building environment with Scons.
For Windows platform (link) linker gets Scons setup
of my share library path with prefix - disk name

I've library on NFS:

libs='\\\\share\\lib\\lib'

In scons I have:

env.Append(LIBPATH = [libs]) 

result is that the linker invokes something like this:

/LIBPATH:D:\share\lib\lib

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

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

发布评论

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

评论(2

北方。的韩爷 2024-08-13 19:07:56

看起来追加功能正在更改您的输入。您是否尝试过通过 __set_item__ 接口操作“LIBPATH”?尝试:

env['LIBPATH'] += ':'+libs

或者

env['LIBPATH'] += ':\\\\share\\lib\\lib'

另外,如果你想摆脱 python \escape-hell,你可以使用字符串前缀 r ,它代表“raw”,并且你的所有 \ 都将不受干扰地通过。

env['LIBPATH'] += r':\\share\lib\lib'

编辑:
为了回应作者的评论并为了调试进一步的尝试:

append_lib_path = r':\\share\lib\lib'
print 'DEBUG: append_lib_path is', append_lib_path

print "DEBUG: before appending to env['LIBPATH'], env['LIBPATH'] is ",env['LIBPATH']

env['LIBPATH'] += append_lib_path

print "DEBUG: after appending to env['LIBPATH'], env['LIBPATH'] is ",env['LIBPATH']

如果您在最后一次打印中看到 env['LIBPATH'] 中的正确值,则 scons 中的其他内容正在破坏您的输入。如果要附加到 lib 路径的字符串不正确,请尝试在 python 解释器中操作该字符串。执行-> <运行...>。然后输入“python”。这将为您提供一个交互式 python 终端,您可以尝试进行字符串操作。如果执行该命令序列不起作用,您可以尝试在某个位置找到 python 安装并双击 python.exe 文件。

It looks like the Append function is changing your input. Have you tried manipulating 'LIBPATH' through the __set_item__ interface? Try:

env['LIBPATH'] += ':'+libs

or

env['LIBPATH'] += ':\\\\share\\lib\\lib'

Also, if you want to get out of python \escape-hell, you can use the string prefix r which stands for "raw" and all your \'s will be passed through unmolested.

env['LIBPATH'] += r':\\share\lib\lib'

EDIT:
In response to the author's comment and in order to debug this further try:

append_lib_path = r':\\share\lib\lib'
print 'DEBUG: append_lib_path is', append_lib_path

print "DEBUG: before appending to env['LIBPATH'], env['LIBPATH'] is ",env['LIBPATH']

env['LIBPATH'] += append_lib_path

print "DEBUG: after appending to env['LIBPATH'], env['LIBPATH'] is ",env['LIBPATH']

If you see the correct value in env['LIBPATH'] on the last print, then something else in scons is mangling your input. If the string you want to append to the lib path is incorrect, try manipulating the string in the python interpreter. Do <Windows start> -> <Run ...>. Then type 'python'. This should give you an interactive python terminal and you can experiment with string manipulation. If doing that sequence of commands doesn't work, you can try to find your python install someplace and double-click the python.exe file.

孤寂小茶 2024-08-13 19:07:56

这里问题的根源是 SCons 将 LIBS 数组中找到的库添加到链接器命令行中 - 带有完整路径。这会导致链接器将此完整路径名保存到生成的可执行文件中,这是不幸的,特别是如果我们正在构建一些稍后将安装到系统目录中的库。我不确定我们是否可以为此归咎于 SCons,因为链接器需要找到用于链接它的库。

到目前为止我只能找到以下两种解决方案:

  • 在同一构建目录中构建库和可执行文件,移动生成的文件
    之后(例如使用 Install() 构建器)。这仅产生名称
    库最终位于
  • 系统目录中已安装库的可执行链接中,并使用该机制
    为了配置正确的依赖关系

两种解决方案似乎都有点尴尬......

PS:(编辑)但是有一个不可移植的解决方案。您可以将特定选项传递给链接器。特别是,在 GNU/Linux 系统上,您可以使用 -h 选项显式设置 DT_SONAME。当库包含此显式设置的 DT_SONAME 字段时,其他库或可执行文件中的任何引用都将仅使用该名称 - 在调用时将精确的解析留给链接器。通常,这正是我们在构建稍后安装到系统中的新库时想要的

The root of the problem here is that SCons adds the libs found in the LIBS array to the linker commandline -- with full path. This results in the linker saving this full pathname into the generated executable, which is unfortunate, especially if we're building some libs which will be installed into a system directory later on. I'm not sure if we can blame SCons for that, because the linker needs to find the library for linking against it.

I could only find the following two solutions up to now:

  • build the libs and the executable in the same build directory, move the generated files
    afterwards (e.g. with the Install() builder). This results in just the name of the
    library ending up in the executable
  • link against already installed libraries in system directories and use the mechanisms
    for configuring the right dependencies

both solutions seem somewhat awkward....

PS: (edit) there is a non-portable solution though. You may pass specific options to the linker. Especially, on a GNU/Linux system, you may explicitly set the DT_SONAME with the -h option. When a library contains this explicity set DT_SONAME field, then any referrals in other libs or executables will just use that name -- leaving the exact resolution to the linker at invokation time. Usually this is exactly what we want, when building a new library to be installed later into the system

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