如何找到此链接器错误的原因? [英] How do I find the cause of this linker error?

查看:32
本文介绍了如何找到此链接器错误的原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过漫长的过程重命名项目后,我的 DLL 项目将无法在调试模式下构建(发布构建工作):

After going through a lengthy process to rename a project, my DLL project will not build in Debug mode (Release builds work):

MSVCRTD.lib(msvcr90d.dll) : error LNK2005: _CrtDbgReportW already defined in LIBCMTD.lib(dbgrpt.obj)

这个项目,以及它所依赖的五个静态库,都设置为使用多线程调试(/MTd)"(在C/C++|代码生成|运行库下).我相信 LIBCMTD.lib 是用于多线程调试的,但 MSVCRTD.lib 是什么,可能导致此错误的原因是什么?

This project, and the five static libraries it depends on, are set to use "Multi-threaded Debug (/MTd)" (under C/C++|Code Generation|Runtime Library). I believe LIBCMTD.lib is the one for multi-threaded debug, but what is MSVCRTD.lib, and what could be causing this error?

如果有区别,这个 DLL 是用于 Windows CE.

If it makes a difference, this DLL is for Windows CE.

推荐答案

LIBCMT 是/MT 所需要的,MSVCRT 是/MD 所需要的.您正在链接混合的 .obj 和 .lib 文件,有些是用/MT 编译的,有些是用/MD 编译的.那不好.

LIBCMT is what you need for /MT, MSVCRT is what you need for /MD. You are linking .obj and .lib files that were mixed, some compiled with /MT some with /MD. That's not good.

通常是 .lib 文件导致了问题.检查它们的构建设置并确保它们的/M 选项与您的 DLL 项目相同.

Usually it is the .lib files that cause the problem. Review their build settings and make sure their /M option is the same as your DLL project.

另外,如果 DLL 是用/MT 编译的,请注意可能会遇到的麻烦.当 DLL 返回指向客户端需要释放的对象的指针时,您将遇到重大问题.它不能,它不使用相同的内存分配器.

Also, beware of the trouble you can get into if the DLL was compiled with /MT. You'll have major problems when the DLL returns pointers to objects that the client needs to release. It can't, it doesn't use the same memory allocator.

这篇关于如何找到此链接器错误的原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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