在 Windows 上构建和部署 dll:SxS、清单和所有爵士乐
从 VS 2005 开始,我发现不可能简单地针对 MS 运行时构建 dll 并将它们部署在一起 ( http://www.ddj.com/windows/184406482)。 我对manifest、SxS和co深感困惑:MSDN文档真的很差,有循环引用; 特别是因为我是一个 Unix 爱好者,所以我发现所有这些都没有提供任何信息。 我的核心问题是将 dll 链接到 msvc9 或 msvc8:由于这些运行时不可重新分发,链接和部署此类 dll 的步骤是什么? 特别是,清单是如何生成的(我不需要 mt.exe,我想要可以跨编译器移植的东西),它们是如何嵌入、使用的? 并排组装是什么意思?
基本上,我在哪里可以找到任何类型的规范而不是 MS 术语?
谢谢所有回答的人,这真的很有帮助,
Since VS 2005, I see that it is not possible to simply build a dll against MS runtime and deploy them together (http://www.ddj.com/windows/184406482). I am deeply confused by manifest, SxS and co: MSDN documentation is really poor, with circular references; specially since I am more a Unix guy, I find all those uninformative. My core problem is linking a dll against msvc9 or msvc8: since those runtime are not redistributable, what are the steps to link and deploy such a dll ? In particular, how are the manifest generated (I don't want mt.exe, I want something which is portable across compilers), how are they embedded, used ? What does Side by side assembly mean ?
Basically, where can I find any kind of specification instead of MS jargon ?
Thank you to everyone who answered, this was really helpful,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
如果您打算部署 Microsoft DLL/.manifest 文件并使用 Java JNI,那么您需要将它们放在 JDK/JRE 的 bin 目录中。
如果您在 JBoss 中运行应用程序,则需要将它们放在 JBoss/bin 目录中。
您可以将 JNI DLL 放在适合您的应用程序的位置。
If you intend to deploy the Microsoft DLLs/.manifest files and are using Java JNI then you will need to put them in the bin directory of your JDK/JRE.
If you are running the app in JBoss, then you will need to put them in the JBoss/bin directory.
You can put your JNI DLL where appropriate for your application.
如果您有要在 MSI 中的“InstallFinalize”操作之前启动的服务或要运行的程序,则不能在 Vista 和 Windows Server 2008 上使用 VC++8 SP1/9 CRT 作为合并模块。
这是因为 dll 是在“InstallFinalize”操作中安装在 WinSXS 中的。
但 MSI“ServiceStart”操作在此之前发生。
因此,请使用引导程序“http://www.davidguyer.us/bmg/publish.htm< /a>"
或者研究在安装程序 4.5 中使用安装程序链接。 但这意味着你需要一个引导程序来安装 4.5,所以这似乎有点毫无意义。
You can't use the VC++8 SP1/9 CRT as a merge module on Vista and windows Server 2008 if you have services you want to start or programs that you want to run before the "InstallFinalize" action in the MSI.
This is because the dlls are installed in WinSXS in the "InstallFinalize" action.
But the MSI "ServiceStart" action comes before this.
So use either a bootstrapper "http://www.davidguyer.us/bmg/publish.htm"
Or look into using the installer chainging in the installer 4.5. But this means you need a bootstrapper to install 4.5 so it seems a bit pointless..
感谢你的回答。 对于部署本身,我可以看到 3 个选项,然后:
Thanks for the answer. For deployment per se, I can see 3 options, then:
它们是可再发行的,并且您在 msvs 目录中有可再发行的软件包。
使用您选择的运行时进行构建,将相应的包添加到您的安装程序中,不用担心 - 它会起作用。 不同之处在于 - 它们现在安装在不同的位置(但这也是您的应用程序要查找库的位置)。
否则,MSDN 或基本上任何不太旧的 Windows C++ 编程书籍。
They are redistributable and you have redistributable packages inside msvs directory.
Build with runtime of your choice, add corresponding package to your installer and don't bother - it will work. The difference is - they are installed in a different place now (but that is also where your app is going to look for libraries).
Otherwise, MSDN or basically any not-too-old book on windows c++ programming.
最简单的事情就是:
假设默认安装 VS2005,您将拥有如下路径:
转到此 redist 文件夹中获取文件,然后将 .manifest 和 msvcr80.dll (至少)放入您的应用程序 .exe 文件夹中。
这些文件存在于安装的根目录中,应该使您的 exe 和所有链接到它们的 dll 能够完美地工作,而无需求助于合并模块、MSI 或任何类型的运行时未安装的即时检测。
The simplest thing to do:
Assuming a default install of VS2005, you will have a path like:
Go, grab the files in this redist folder, and place the .manifest AND the msvcr80.dll (At least) in your applications .exe folder.
These files, present in the root of your installation, should enable your exe and all dlls linked against them, to work flawlessly without resorting to merge modules, MSIs or indeed any kind of just-in-time detection that the runtime is not installed.
以下是博客条目解释了 SxS crt 决策背后的合理性VC++。 它包括解释静态链接 crt 有多么糟糕,以及为什么不应该这样做。
这是有关如何静态链接 crt 的文档。
Here is the blog entry explaining the rational behind the SxS crt decision for VC++. It includes explaining how bad it is to statically link the crt, and why you shouldn't do that.
Here is the documentation on how to statically link the crt.
嗯,我遇到过其中一些问题,所以也许我的一些评论会有所帮助。
您可能需要在 Vista 上进行测试以确保其正常工作。
Well, I've encountered some of these issues, so perhaps some of my comments will be helpful.
You'll probably want to test on Vista to make sure this is working properly.
我们在所有应用程序中使用一个简单的包含文件 DLL 的 vcmanifest.h,然后将所有项目设置为嵌入清单文件。
vcmanifest.h
We use a simple include file in all our applications & DLL's, vcmanifest.h, then set all projects to embedded the manifest file.
vcmanifest.h