• vs编译错误 error 1047 & 二进制兼容性的限制


    先看以下微软官方的解释:
    There are three important restrictions on binary compatibility between the the v140, v141, and v142 toolsets and minor numbered version updates:
    
    
    You can mix binaries built by different versions of the v140, v141, and v142 toolsets.
    However, you must link by using a toolset at least as recent as the most recent binary in your app.
    Here's an example: you can link an app compiled using any 2017 toolset (v141, versions 15.0 through 15.9) to
    a static library compiled using, say, Visual Studio 2019 version 16.2 (v142), if they're linked using a version 16.2 or later toolset.
    You can link a version 16.2 library to a version 16.4 app as long as you use a 16.4 or later toolset.
    
    
    The Redistributable your app uses has a similar binary-compatibility restriction.
    When you mix binaries built by different supported versions of the toolset,
    the Redistributable version must be at least as new as the latest toolset used by any app component.
    
    
    Static libraries or object files compiled using the /GL (Whole program optimization) compiler switch
     or linked using /LTCG (Link-time code generation) aren't binary-compatible across versions,
    including minor version updates. All object files and libraries compiled using /GL and /LTCG must
    use exactly the same toolset for the compile and the final link. For example, code built by using /GL in the Visual Studio 2019
    version 16.7 toolset can't be linked to code built by using /GL in the Visual Studio 2019
    version 16.8 toolset. The compiler emits Fatal error C1047.
    
    
    翻译一下:
    1.对于v140、v141、v142工具集和次要版本更新之间的二进制兼容性,有三个重要的限制:
    可以混合使用不同版本v140、v141和v142工具集生成的二进制文件。但是,必须用至少与应用中最新的二进制库一致或更新的工具集进行链接。举例:
    你可以在一个使用2017工具集(v141,版本15.0到15.9)编译的应用中链接使用16.2版本2019(v142)编译的静态库,前提是使用16.2或更新的工具集。
    你可以将16.2的库链接到16.4的应用中,只要你使用16.4或更新的工具集
    
    
    2.使用可再发行包也有相似的二进制兼容限制。当你混合由不同版本工具集编译的二进制库时,可再发行包必须至少与最新近的组件一致。
    
    
    3.使用/GL(全局优化)编译选项或/LTCG(链接时代码生成)链接选项编译静态库或对象文件时在不同版本间是二进制不兼容的。所有使用/GL和/LTCG的对象文件
    和库编译链接时必须使用相同的工具集。举例:使用16.7工具集启用/GL生成的代码不能链接到使用16.8工具集启用/GL的库,编译器会报错C1047。
    
    
    参考:
    https://docs.microsoft.com/zh-cn/cpp/porting/binary-compat-2015-2017?view=msvc-160
    https://blog.csdn.net/u014744118/article/details/48261595
    https://www.cnblogs.com/totogo/p/14475263.html
    https://blog.csdn.net/ly90907/article/details/100118722
    https://stackoverflow.com/questions/64571556/link-error-on-visual-studio-2015-when-using-library-built-on-visual-studio-2019
  • 相关阅读:
    常用颜色
    在VS2010中打开VS2012的项目
    vs2012 断点不能调试
    Setup Factory 打包.netframework 2.0
    Access 中数据库操作时提示from子句语法错误
    vs2012 .netFramwork2.0发布到xp
    c# access插入null值
    Visual Studio安装卸载模板
    Codeforces 455D
    ACdream 1157 (cdq分治)
  • 原文地址:https://www.cnblogs.com/nuoforever/p/15238681.html
Copyright © 2020-2023  润新知