包括 Visual C++ 上的间接
假设我们有一个需要 Boost 来编译的应用程序。 Boost 是一个外部库,定期更新,并且我们的应用程序具有多个二进制文件和多个版本(“多个”如“让它们生长和繁殖”...不要问...),我们需要一个易于更新/维护的间接方式,以便为每个应用程序的版本链接到正确的 Boost 版本。
例如:
- MyApp 8.0 => Boost 1.34
- MyApp 8.1 => Boost 1.35
- MyApp 9.0 => Boost 1.35
- MyApp 10.0 => Boost 1.37
在 Linux 文件系统上,我们将创建一个重定向到正确的 boost 目录的符号链接:
- MyApp 8.0 => MyAppBoostLink_8.0 => Boost 1.34
- MyApp 8.1 => MyAppBoostLink_8.1 => Boost 1.35
- MyApp 9.0 => MyAppBoostLink_9.0 => Boost 1.35
- MyApp 10.0 => MyAppBoostLink_10.0 => Boost 1.37
这将使我们能够轻松更新 MyApp 10.0,以便在 Boost 1.38 可用时与它链接,只需替换符号链接即可。
但在 Windows 上,这不起作用(或者我错过了一些东西)。
Boost 本身似乎放弃了这个想法:对于 BJam,我记得看到警告说 BJam 正在复制 lib 文件,因为符号链接在 WinNT 上不起作用。 我尝试了另一种方法,因为我们使用 Visual C++,但没有任何编译指示可以解决此问题(我搜索了为标头包含和库链接添加默认搜索目录的编译指示,但没有找到)。
我不敢相信我需要启动一个脚本来签出 VCPROJ 文件(Visual C++ XML makefile),更新 Boost 包含,然后签入修改,但我没有看到其他解决方案,直到 Windows 有工作符号链接(或者我发现如何创建它们)。
有更好的主意吗?
编辑
当我们将编译器从 Visual C++ 2003 更新到 Visual C++ 2008 时,问题就消失了。显然,Visual C++ 2008 可以看到跨网络的符号链接。
Let's say we have an application that will need Boost to compile. Boost being an external library, updated regularly, and our application having multiple binaries and multiple versions ("multiple" as in "Let them grow and multiply"... don't ask...), we need an easy to update/maintain indirection to have for each app's version link with the right Boost version.
For example:
- MyApp 8.0 => Boost 1.34
- MyApp 8.1 => Boost 1.35
- MyApp 9.0 => Boost 1.35
- MyApp 10.0 => Boost 1.37
On a Linux filesystem, we would create a symbolic link redirecting to the right boost directory:
- MyApp 8.0 => MyAppBoostLink_8.0 => Boost 1.34
- MyApp 8.1 => MyAppBoostLink_8.1 => Boost 1.35
- MyApp 9.0 => MyAppBoostLink_9.0 => Boost 1.35
- MyApp 10.0 => MyAppBoostLink_10.0 => Boost 1.37
This would enable us to easily update MyApp 10.0 to link with Boost 1.38 when it will be available, just by replacing the symbolic link.
But on Windows, this does not work (or I missed something).
Boost itself seems to give up on the idea: With BJam, I recall seeing warnings saying BJam was copying the lib files because symbolic links did not work on WinNT. I tried an alternative, as we use Visual C++, but no pragma resolves this problem (I searched for a pragma adding default search directories for header includes and library links, but found none).
I can't believe I'll need to launch a script to check-out the VCPROJs files (Visual C++ XML makefiles), to update the Boost includes, and then check-in the modifications, but I see no other solution until Windows have working symbolic links (or either I discover how to create them).
Is there a better idea?
Edit
The problem disappeared when we updated our compiler, from Visual C++ 2003 to Visual C++ 2008. Apparently, Visual C++ 2008 sees symbolic links across networks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NTFS 文件系统上的 Windows 符号链接等效项称为联结:http://technet.microsoft。 com/en-us/sysinternals/bb896768.aspx
Windows symlinks equivalent on NTFS filesystems is called junctions: http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx
您可以将 boost 安装的基本目录保留在特定于版本的环境变量中,该变量在 VS2008 的“启动批处理文件”中设置。 这可能不像在构建过程中必须操作 .vcproj 文件那么难看。 大概...
You could keep the base directory of the boost installation in a version-specific environment variable that gets set in a "starter batch file" for VS2008. This is probably not quite as ugly as having to manipulate .vcproj files as part of the build process. Probably...