链接器错误:文件无效或损坏:重复COMDAT [英] Linker error : invalid or corrupt file: duplicate COMDAT

查看:214
本文介绍了链接器错误:文件无效或损坏:重复COMDAT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我有一个包含一个函数的模板类时,遇到了这个问题,该函数包含一个具有初始化程序的模板外部的类的静态变量。



我修复了它通过移动模板外部的静态,确实使其成为一个外部。



/ Bevin

I encountered this when I had a template class containing a function containing a static variable of a class from outside the template that had an initializer.

I fixed it by moving the static outside the template, indeed making it an extern.


/Bevin

推荐答案

嗨Bevin,

Hi Bevin,

感谢您在这里发帖。

>>当我有一个模板类包含一个包含模板外部类的静态变量的函数时遇到了这个有一个初始化程序。

那么现在你的案例已经解决了什么问题?

So what's the problem now as your case has been solved?

您还可以检查项目的属性 - > C / C ++ - >代码生成 - >启用功能级链接属性。将其设置为No(/ Gy - )。

You could also check your project's Property->C/C++->Code Generation->Enable Function-Level Linking property. Set it to No (/Gy-).

COMDAT部分的目的是允许"复制"部分。要在多个目标文件中定义的部分。并且/ Gy选项将允许编译器以打包函数(COMDAT)的形式打包单个函数。

The purpose of a COMDAT section is to allow "duplicate" sections to be defined in multiple object files. And the /Gy option will allow the compiler to package individual functions in the form of packaged functions (COMDATs).

希望这可以帮到你。

最诚挚的问候,

Sera Yu


这篇关于链接器错误:文件无效或损坏:重复COMDAT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆