我曾经遇到的Link2001的错误
来源:互联网 发布:淘宝店代销怎么做 编辑:程序博客网 时间:2024/04/30 14:17
1.错误现象:
Linking...
LINK : warning LNK4075: ignoring /EDITANDCONTINUE due to /INCREMENTAL:NO specification
Creating library skexcel___Win32_Release/skexcel.lib and object skexcel___Win32_Release/skexcel.exp
SK_Excel.obj : error LNK2001: unresolved external symbol "public: void __thiscall EXCEL::_Worksheet::SetName(unsigned short const *)" (?SetName@_Worksheet@EXCEL@@QAEXPBG@Z)
SK_Excel.obj : error LNK2001: unresolved external symbol "public: struct IDispatch * __thiscall EXCEL::Sheets::Add(struct tagVARIANT const &,struct tagVARIANT const &,struct tagVARIANT const &,struct tagVARIANT const &)" (?Add@Sheets@EXCEL@@QAEPAUID
ispatch@@ABUtagVARIANT@@000@Z)
../../../bin/Client/Release/skexcel.dll : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
skexcel.dll - 3 error(s), 1 warning(s)
分析:造成上述2001的错误的原因有三:
1. 头文件中声明了某个函数,但是在CPP文件中没有实现它
2. 如果某个函数是在 A.H 和 A.CPP中声明和实现,在B.CPP中调用,则是没有包含 A.H 和 A.CPP
3. 没有将对应的Lib文件添加到工程中...(Project-->Setting-->Link)(暂时不理解)
补充个问题:
1.在2011年03月31日,我合并代码的时候,用Merge拷贝代码从低版本到高版本中去,但却没有在工程中手动添加关联文件,也会出现
这种错误...特此标记
权威解释:
MSDN: http://msdn.microsoft.com/en-us/library/Aa234493
一个类似的问题的解释:
error LNK2019: unresolved external symbol (下面的不是很理解,类似于SDK的包含等)
http://www.cplusplus.com/forum/general/12144/
Okay, I've never used whatever library it is you're using (I don't even know what CORBA is, actually), but the ordinary method for linking to a library with VC++ is this:
You should have gotten with the library at least the first two of these three:
1. One or more headers that tell the compiler what the functions look like. You obviously have this, or you'd be getting compiler errors.
2. One or more .libs that defines some or all of the functions, and tells the linker to shut up about the ones that aren't defines.
3. One or more DLLs that will be linked to the program at run time if some of the functions weren't fully defined by the .libs.
Now, assuming you have number 2, you should put it somewhere where the compiler can find them. I would set aside a directory in My Documents to put all .libs and then add it to the compiler list in tools>options>projects and solutions>VC++ directories>show directories for: library files. If you're feeling lazy, you can just leave them in one of the directories that are already listed there (e.g. "$(VSInstallDir)lib").
Next, you need to add their file names (not their full path. It will still work if you add the full path, but it's unnecessary thanks to the previous step) to that option you mentioned (Configuration Properties -> Linker -> Input -> Additional Dependencies). Don't forget the file name extensions.
That should clear the linker errors.
- 我曾经遇到的Link2001的错误
- 使用Q_OBJECT宏遇到的LINK2001错误
- 常见的Link2001错误【转贴】
- VC++的链接错误LINK2001
- 一次Link2001错误的解决
- 让我曾经蛋疼的错误
- 那些曾经陪伴我的低端错误
- Qt下Link2019,Link2001错误的解决
- 曾经的我
- 遇见曾经的我
- 曾经的我
- 我曾经的梦想
- 曾经的你,曾经的我
- 那些我曾经犯过的低级编程错误
- 各种曾经遇到的ERROR
- Link2001常见错误以及VC6.0工程文件的用途
- 关于LINK2001错误的一些总结(转)
- LINK2001 编译时_RTC_Shutdown和_RTC_InitBase相关错误的解决方法
- 页面加载完毕,执行多个JS函数
- 表空间不足
- Java学习攻略 MLDN讲师 李兴华
- qsort函数用法大全
- html css 标题背景 折边凸显效果,有点意思,记录下
- 我曾经遇到的Link2001的错误
- Visual Studio
- 项目延期一定要以加班来弥补吗?
- POJ 1330 Nearest Common Ancestor
- Linux下使用一些常用的svn命令
- Oracle 数据库迁移方法
- 刷新按钮 新增一条数据
- 2011读书计划 - 50本书
- Q_DECLARE_METATYPE与qRegisterMetaType学习