C++ 使用 Visual Studio 2012 并使用旧平台工具集进行编译?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15453629/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 19:23:28  来源:igfitidea点击:

Use Visual Studio 2012 and compile with older platform toolset?

c++visual-studiodllvisual-studio-2012visual-c++-runtime

提问by bytecode77

The problem

问题

I'm using Visual Studio 2012 to develop C++ DLLs. On some machines these DLLs can not be loaded, because the platform toolset, which is set to "v110" is missing.

我正在使用 Visual Studio 2012 来开发 C++ DLL。在某些机器上,无法加载这些 DLL,因为缺少设置为“v110”的平台工具集。

I have tried to install older c++ runtimes. They didn't install because "a newer version is already installed". I also installed the current Windows SDK, but there are still no other items to choose from than v110.

我尝试安装较旧的 c++ 运行时。他们没有安装,因为“已经安装了较新的版本”。我也安装了当前的 Windows SDK,但除了 v110 之外仍然没有其他项目可供选择。

Question

How can I compile my C++ DLL with an older version of the C++ runtime so it will run on non-developer machines?

如何使用旧版本的 C++ 运行时编译我的 C++ DLL,以便它可以在非开发人员的机器上运行?

Platform toolset is v110

平台工具集是 v110

采纳答案by Roger Lipscombe

According to this page on MSDN, you need to have the corresponding version of Visual Studio (2008 or 2010), or the relevant Windows SDK for the "Platform Toolset" drop down to list those versions:

根据MSDN上的这个页面,您需要具有相应版本的 Visual Studio(2008 或 2010),或“平台工具集”下拉列表中的相关 Windows SDK 以列出这些版本:

To change the target platform toolset, you must have the associated version of Visual Studio or the Windows Platform SDK installed.

要更改目标平台工具集,您必须安装相关版本的 Visual Studio 或 Windows 平台 SDK。

You also seem to be a little bit confused between "Platform Toolset", which controls which compiler/linker/etc. is used to buildyour application, and "Visual C++ Redistributable", which is needed to runyour application. You can't install a "Platform Toolset" on a user's PC, and nor will you make one available by installing a particular "Visual C++ Redistributable" on your development PC.

您似乎也对控制哪个编译器/链接器/等的“平台工具集”有些困惑。用于构建您的应用程序,以及运行您的应用程序所需的“Visual C++ Redistributable” 。您不能在用户的 PC 上安装“平台工具集”,也不能通过在开发 PC 上安装特定的“Visual C++ Redistributable”来使其可用。

Also, as far as I know, the Visual C++ Redistributable doesn't include the MFC runtimes. They're available as a separate MSI merge module (MSM).

此外,据我所知,Visual C++ Redistributable 不包括 MFC 运行时。它们可作为单独的 MSI 合并模块 (MSM) 使用。

回答by bytecode77

I'd like to share some information, which I came across and figured out how to use them for my purpose.

我想分享一些信息,我遇到并想出了如何将它们用于我的目的。

Apparently it is a good option to use static linking. It didn't always work for me, but for a smaller project of mine, it works quite good. And the result is a DLL with no dependencies other than kernel32.dlland the like.

显然,使用静态链接是一个不错的选择。它并不总是对我有用,但对于我的一个较小的项目,它工作得很好。结果是一个 DLL,除了kernel32.dll诸如此类之外没有任何依赖项。

Simply use /MTfor release configuration and /MTdfor debug and you'll be fine.

简单地/MT用于发布配置和/MTd调试,你会没事的。

The problem here is that a developer like me gets the current Visual Studio version, shortly after its release, but you can't really expect common users to have runtimes installed which are only a few weeks old. And installing different versions of Visual Studio just to use the old runtime is definitely not what you want.

这里的问题是,像我这样的开发人员在发布后不久就获得了当前的 Visual Studio 版本,但您真的不能指望普通用户安装只有几周的运行时。而仅仅为了使用旧的运行时而安装不同版本的 Visual Studio 绝对不是你想要的。

Static linking in Visual Studio 2013

Visual Studio 2013 中的静态链接

回答by bernie3280109

A hint for the internet archive. (I cannot comment the statements above, I don't know why)

互联网档案馆的提示。(我不能评论上面的陈述,我不知道为什么)

To use the v90 platform toolset (=Visual Studio 2008)in a newer Visual Studio (I testet 2013 and 2015) you need to install Visual Studio 2008 and additionally Visual Studio 2010, because the vs90 platform toolset definitions in the MS Build programs folder are part von Visual Studio 2010.

要在较新的 Visual Studio(我测试 2013 和 2015)中使用v90 平台工具集(=Visual Studio 2008),您需要安装 Visual Studio 2008 和另外的 Visual Studio 2010,因为 MS Build 程序文件夹中的 vs90 平台工具集定义是部分 von Visual Studio 2010。

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\PlatformToolsetsfor v90 and v100

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\PlatformToolsets对于 v90 和 v100

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0

for V110 V120 and V140

用于 V110 V120 和 V140

representing Visual Studio Versions: v90=2008, v100=2010, V110=2012, V120=2013, V140=2015.

代表 Visual Studio 版本:v90=2008、v100=2010、V110=2012、V120=2013、V140=2015。

After the Installation vob VS2010 the newer Visual Studio 2013 and 2015 Versions could use the vs90 and vs100 platform toolsets. (This works immidiadtly without a new installation of Visual Studio 2013/2015.) I guess Visual Studio 2012 is doing it the same way like VS2013 and VS2015.

在安装 vob VS2010 之后,较新的 Visual Studio 2013 和 2015 版本可以使用 vs90 和 vs100 平台工具集。(这在没有新安装 Visual Studio 2013/2015 的情况下立即有效。)我猜 Visual Studio 2012 的操作方式与 VS2013 和 VS2015 相同。

回答by 4pie0

well it depends what you are trying to build. Some things are maybe supported via installing Windows SDK 7.1. see this post, same question, but if your project is dependent upon MFC then unfortunately it looks like it's not possible at all, mainly because nothing but VS2010 is deploying the MFC libraries.

好吧,这取决于您要构建的内容。有些东西可能通过安装 Windows SDK 7.1 来支持。看到这个帖子,同样的问题,但如果你的项目依赖于 MFC,那么不幸的是它看起来根本不可能,主要是因为除了 VS2010 之外什么都没有部署 MFC 库。