【问题标题】:Visual Studio 2015 link against MFC42针对 MFC42 的 Visual Studio 2015 链接
【发布时间】:2015-09-09 08:06:49
【问题描述】:

我最近继续了一个我曾经使用 MFC 使用 Visual Studio 6 开发的项目。
我至少有 4 年没有碰过代码了。
这一切都在 VS6 上编译得很好。
但是现在我安装了 VS2015,转换了项目并修复了一些在 VS2015 上无法编译的代码。
所以一切都很顺利。但是当我尝试在干净的 Windows 10 系统上启动 exe 时,它​​说缺少运行时 dll(例如 MFC140u.dll) 我知道我可以安装 VC++ 发行版来让我的应用程序正常工作,但我的应用程序的大小只有 325kB。 但我可以看到 MFC42u.dll 在这个空白的 Win 10 系统上。所以已经有一个包含 MFC 的 VC++ 运行时。 我只是不想在每个系统上都安装一个新的 VC++ 运行时,为什么不使用现有的呢?

谁能告诉我在使用VS2015时如何链接到MFC42?
提前致谢。

【问题讨论】:

  • 据我所知,您需要在 exe 中包含 MFC14 dll。 MFC42 与 VS6 相关。正如您现在使用 VS2015 编译的那样,您的应用程序现在使用 MFC14 dll。不能用安装程序打包吗?
  • 对于 325kb 的应用程序要打包大约 5mb?那对我来说没有选择。我仍然可以使用 VS6 编译应用程序并且它会运行,但这不是我满意的工作流程。
  • 不能选择静态链接 MFC?
  • 我在项目设置中选择了“在静态库中使用 MFC”,但这并没有改变任何东西。空白的win10系统仍然抱怨缺少MFC dll。甚至 exe 的大小都与我选择“在共享 Dll 中使用 MFC”相同
  • 该文件仅供 Microsoft 私人使用,不适合一般应用程序使用。您没有它的导入库,因此您无法说服链接器使用它。只运行redist installer 是非常简单的解决方案。

标签: c++ mfc visual-studio-2015


【解决方案1】:

想知道为什么这个 Q 被否决了。
但答案是:不可能。

【讨论】:

    【解决方案2】:

    如果您不想打包 vc 可再发行组件,请在安装期间从 Microsoft 下载它们!

    在带有InnoSetup Dependency InstallerInnoSetup 脚本中,这看起来像

    [Languages]
    Name: "en"; MessagesFile: "compiler:Default.isl"
    Name: "de"; MessagesFile: "compiler:Languages\German.isl"
    
    [Code]
    // shared code for installing the products
    #include "scripts\products.iss"
    // helper functions
    #include "scripts\products\stringversion.iss"
    #include "scripts\products\winversion.iss"
    #include "scripts\products\fileversion.iss"
    // actual products       
    #include "scripts\products\msiproduct.iss"
    #include "scripts\products\vcredist2015.iss"
    
    // Perform some initializations.  Return False to abort setup
    function InitializeSetup: Boolean;
    begin
      initwinversion();
      SetForceX86(true); // force 32-bit install of next products
      vcredist2015();
      SetForceX86(false); // disable forced 32-bit install again
    end;
    

    鉴于您的应用从 VS6 升级后仍然只有 32 位。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-24
      • 2016-08-21
      • 2016-02-01
      • 2016-03-21
      • 1970-01-01
      • 2017-06-05
      • 1970-01-01
      相关资源
      最近更新 更多