奇怪的LNK2001链接器错误 [英] Strange LNK2001 linker error

查看:455
本文介绍了奇怪的LNK2001链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天我收到此链接器错误.我在google和msdn上搜索都没有成功. 我的问题: 我已经将cpp项目的某些部分移到了外部静态库中.我将h文件添加到了我的主项目中,并将依赖项添加到了lib文件中.不幸的是,我收到很多链接器错误.

Yesterday I got this linker error. I have searched on google and msdn without success. My problem: I have moved some parts of my cpp project in a extern static library. I added the h file to my main project and added the dependencies to the lib files. Unfortunately I get a lot linker errors.

1>Compressor.obj : error LNK2001: unresolved external symbol "public: bool __thiscall NWindows::NFile::NFind::CFileInfo::Find(unsigned short const *)" (?Find@CFileInfo@NFind@NFile@NWindows@@QAE_NPBG@Z)
1>Compressor.obj : error LNK2001: unresolved external symbol "public: class NWindows::NCOM::CPropVariant & __thiscall NWindows::NCOM::CPropVariant::operator=(unsigned short const *)" (??4CPropVariant@NCOM@NWindows@@QAEAAV012@PBG@Z)
1>Compressor.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CInFileStream::Open(unsigned short const *)" (?Open@CInFileStream@@QAE_NPBG@Z)
1>Compressor.obj : error LNK2001: unresolved external symbol "public: bool __thiscall NWindows::NFile::NIO::COutFile::Create(unsigned short const *,bool)" (?Create@COutFile@NIO@NFile@NWindows@@QAE_NPBG_N@Z)
1>Compressor.obj : error LNK2001: unresolved external symbol "void __cdecl ConvertUInt32ToString(unsigned int,unsigned short *)" (?ConvertUInt32ToString@@YAXIPAG@Z)
1>Compressor.obj : error LNK2001: unresolved external symbol "public: bool __thiscall NWindows::NDLL::CLibrary::Load(unsigned short const *)" (?Load@CLibrary@NDLL@NWindows@@QAE_NPBG@Z)

所有这些方法都是我的外部库的一部分.我尝试了很多编译器设置,但均未成功. 此外,当我从链接器中完全删除lib依赖项时,我收到26 LNK2001错误.因此,链接器仅找到lib的部分". 我为我的项目使用了错误的编译器/链接器选项吗?

All this methods a part of my extern lib. I have tries a lot of compiler settings without success. Further more when I remove the lib dependencie completely from the linker I get 26 LNK2001 error. So the linker finds only "parts" of the lib. Do I use a wrong compiler / linker option for my projects?

问题在于方法CLibrary :: Load(LPCTSTR fileName)的参数定义LPCTSTR.在我的库中,我将选项将wchar_t作为内置类型处理(Properties-> C/C ++-> Lanuage-> ...)"设置为No.现在可以使用了.

edit: The problem was the parameter define LPCTSTR of the method CLibrary::Load(LPCTSTR fileName). In my lib I set the option "Treat wchar_t as build-in type (Properties->C/C++->Lanuage-> ... ) to No. And now it works.

推荐答案

问题中没有足够的信息,所以我的回答仅作为指导.

There's not enough information in the question so my answer merely serves as a guide.

采用一个函数,例如bool NWindows::NFile::NFind::CFileInfo::Find(unsigned short const *),并在您的代码中找到它的定义.有吗有了这个确切的功能签名?它在未命名的命名空间中吗?它在源文件中声明为静态吗?

Take one function, for instance bool NWindows::NFile::NFind::CFileInfo::Find(unsigned short const *) and find definition of it in your code. Is it there? With this exact function signature? Is it in unnamed namespace? Is it declared static in source file?

此外,请尝试完全重建所有内容.您会感到惊讶的是,完全重建使神秘问题消失了多少次.

Also, try full rebuild of everything. You'd be surprised how many times full rebuild makes mysterious problems go away.

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

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