【发布时间】:2012-08-04 13:30:15
【问题描述】:
我继承了一个包含 3 个项目的 C++ 解决方案,一个编译为 .DLL,另外两个编译为 .EXE。 DLL 可以自行构建,但其他两个在构建时会产生大约 65 个 LNK2005 错误,其中大部分是引用同一个 .obj 文件,如下面的日志所示:
Linking...
Function.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification
Function.obj : error LNK2005: _ReadLocalRegister already defined in Function.obj
Function.obj : error LNK2005: _getSource already defined in Function.obj
Function.obj : error LNK2005: _SendLogEvent already defined in Function.obj
Function.obj : error LNK2005: _DebugMsg already defined in Function.obj
Function.obj : error LNK2005: _MyInformationMsg already defined in Function.obj
MyNTService.obj : error LNK2005: "public: __thiscall CMyNTService::CMyNTService(void)" (??0CMyNTService@@QAE@XZ) already defined in MyNTService.obj
MyNTService.obj : error LNK2005: "public: virtual void __thiscall CMyNTService::OnStop(void)" (?OnStop@CMyNTService@@UAEXXZ) already defined in MyNTService.obj
MyNTService.obj : error LNK2005: "public: void __thiscall CMyNTService::SaveStatus(void)" (?SaveStatus@CMyNTService@@QAEXXZ) already defined in MyNTService.obj
....就这样继续下去!
我是一名 C# 编码员,只有基本的 C++ 知识,所以我对此感到迷茫。该解决方案是一个已有 15 年历史的 C 解决方案,我试图在 VS2008 中将其重建为 C++ 解决方案。我已经成功构建过一次,没有任何变化,但也许从那时起一些配置设置发生了变化。
有没有人知道我可以从哪里开始寻找...?
非常感谢!
【问题讨论】:
-
您是否有包含这些函数的定义的头文件(即扩展名为
.h并包含在#include指令中的文件)? IE。整个函数和代码在使用的头文件之一中吗?
标签: c++ visual-studio-2008 compiler-construction lnk2005