.crt 部分?这个警告是什么意思?
我最近收到此警告(VC++ 2010)
警告 LNK4210:.CRT 部分存在;可能有未处理的静态初始化程序或终止符
我假设这是关键部分。我的操作系统课程已经有一段时间了,所以我无法真正弄清楚这意味着什么。如果我没记错的话,关键部分使用共享资源。那么这个警告有什么关系,它到底意味着什么?
I've got this warning recently (VC++ 2010)
warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
I'm assuming this is the Critical Section. It's been a while since my Operating Systems course, so I can't really figure out what this means. If I remember right, the Critical Section works with shared resources. So how is this warning related and what does it mean exactly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
不,CRT = C 运行时间。它是任何程序完成工作所需的支持库。像 strcpy() 这样的东西就在那里。当您的代码包含需要在程序开始运行之前初始化的全局变量时,您的 .obj 文件中会出现“.CRT 部分”。 CRT 负责处理这个问题。
这没什么不寻常的。问题是链接器没有看到 CRT 链接到您的程序中。除了初始化要求之外,您以某种方式编写了不依赖于 CRT 代码的代码。很奇怪,从来没有听说过有人遇到这个问题。请按照文档中的清单查看其中是否有符合你的情况。
No, CRT = C Run Time. It is support library that any program needs to get the job done. Stuff like strcpy() lives there. You get a '.CRT section' in your .obj file when your code contains global variables that need to be initialized before your program starts running. The CRT takes care of that.
That is nothing unusual. The problem is the linker didn't see the CRT getting linked into your program. You somehow wrote code that didn't have any dependency on the CRT code, other than the initialization requirement. Very strange, never heard of anybody having this issue. Follow the checklist in the documentation to see if one of them matches your case.
MSDN 文档很好地介绍了这一点:
因此,我会检查您的代码是否最近添加了在静态或全局范围内创建的对象。如果您没有找到任何内容,它们可能隐藏在您正在链接的第三方库中。无论哪种方式,最可能的解决方案是使用上面“解决此问题”部分中的第一个建议与 CRT 链接。
The MSDN docs cover this pretty well:
So I would check your code for the recent addition of objects created at static or global scope. If you don't find any, they may be hiding within a 3rd-party library which you're linking with. Either way, the most likely solution will be to link with CRT using the first suggestion in the "To fix this problem" section above.
警告 LNK4210:.CRT 部分存在;可能存在未处理的静态初始值设定项或终止符
此错误是由于项目属性中入口点的规范引起的。
按照以下步骤操作,看看您的错误是否得到解决:
1. 在解决方案资源管理器中右键单击您的项目 (VS 2013)
2. 转到属性 - 所有配置
3. 链接器 - 入口点。如果指定了入口点,请删除该入口点。
无需指定入口点,因为 BOOST_TEST 会自动检测入口点。
希望这也有助于解决其他初始化程序错误。干杯!
warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
This error is caused due to the specification of the entry point in project properties.
Follow the steps below and see if your error gets resolved:
1.Right click on your Project in solution explorer(VS 2013)
2.Go to properties- All Configurations
3.Linker- Entry Point. Delete the entry point if you have specified any.
There is no need to specify the entry point as the BOOST_TEST detects the entry point automatically.
Hope this helps for other innitializer errors as well. Cheers!
我通过手动指定 DLL 的“自定义”条目也遇到了同样的问题。我删除了那个自定义 DLL 条目,只使用默认名称 DLLMain,它又可以工作了……奇怪。
I have had the same problem by manually specifying a "custom" entry to my DLL. I removed that custom DLL entry and am simply using the default name DLLMain and it works again...odd.
LIBCMT.LIB 初始化 CRT 相关的东西....
使用mainCRTStartup作为入口函数,然后显式调用_CRT_INIT。
LIBCMT.LIB to initialize the CRT related stuffs....
Use mainCRTStartup for entry function, then call _CRT_INIT explicity.
如果您不调用
_CRT_INIT
,链接器将显示有关“警告 LNK4210:.CRT 部分存在;可能存在未处理的静态初始化程序或终止符”的警告。If you don't call
_CRT_INIT
, the linker will show the warnings about "warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators".