奇怪的LNK2001链接器错误
Strange LNK2001 linker error
昨天我收到了这个链接器错误。我在谷歌和msdn上搜索过,但没有成功。我的问题:我已经在外部静态库中移动了cpp项目的一些部分。我将h文件添加到我的主项目中,并将依赖项添加到lib文件中。不幸的是,我收到了很多链接器错误。
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)
所有这些方法都是我外部库的一部分。我尝试了很多编译器设置,但都没有成功。此外,当我从链接器中完全删除库依赖性时,我会得到26 LNK2001错误。因此,链接器只查找lib的"部分"。我的项目是否使用了错误的编译器/链接器选项?
编辑:问题是方法CLibrary::Load(LPCTSTR fileName)的参数定义LPCTSTR。在我的库中,我将选项"将wchar_t视为内置类型(Properties->C/C++->Lanuage->…)"设置为No。现在它可以工作了。
问题中没有足够的信息,所以我的回答只是一个指南。
以一个函数为例,bool NWindows::NFile::NFind::CFileInfo::Find(unsigned short const *)
,并在代码中找到它的定义。它在那里吗?有这个确切的函数签名吗?它在未命名的命名空间中吗?它在源文件中声明为静态吗?
此外,尝试全面重建一切。你会惊讶于有多少次完全重建会让神秘的问题消失。
相关文章:
- Netbeans 10:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- CMake 错误:链接器命令失败,退出代码为 1 和 cpp.o 文件
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) - 体系结构的未定义符号 x86_64:
- 如何修复 clang: 错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- Android NDK.Build命令失败.未定义的引用.clang++:错误:链接器命令失败,退出代码为1
- 使用cmake错误链接boost日志
- 错误:链接器命令失败,退出代码为 1(使用 -v 查看调用):在 Macbook 上
- C++ XCODE ld:找不到体系结构x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -
- clang:错误:链接器命令失败,C++代码中的退出代码为 1(使用 -v 查看调用)
- 静态库中的 g++ 错误链接函数
- 未定义的参考错误链接天然函数Android
- C++编译错误:ld:找不到体系结构x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v
- QT Q_PROPERTY错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- ld:找不到体系结构x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- OSX MOJAVE -LD:架构X86_64 clang找不到符号:错误:链接器命令失败,出口代码1
- C 错误链接器命令失败了出口代码1(使用-V查看调用)
- LD:架构x86_64 clang找不到符号:错误:链接器命令失败,出口代码1(使用-v to See
- 聚输出错误 - 链接列表
- Xcode链接器错误:链接器命令失败,退出代码为1(使用-v查看调用)
- 尝试构建C DLIB示例无法与数百个未定义的参考错误链接