无法解析的外部符号

cc___999 2013-08-06 10:56:58

1>ProgramCommonLibForEngine_d.lib(Profiler.obj) : error LNK2001: 无法解析的外部符号 "long const std::_BADOFF" (?_BADOFF@std@@3JB)
1>ProgramCommonLibForEngine_d.lib(WzMemoryTracker.obj) : error LNK2001: 无法解析的外部符号 "long const std::_BADOFF" (?_BADOFF@std@@3JB)
1>ProgramCommonLibForEngine_d.lib(Clock.obj) : error LNK2001: 无法解析的外部符号 "long const std::_BADOFF" (?_BADOFF@std@@3JB)
1>ProgramCommonLibForEngine_d.lib(Profiler.obj) : error LNK2019: 无法解析的外部符号 "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ),该符号在函数 "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::append(char const *,unsigned int)" (?append@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@PBDI@Z) 中被引用
1>ProgramCommonLibForEngine_d.lib(WzMemoryTracker.obj) : error LNK2001: 无法解析的外部符号 "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
1>ProgramCommonLibForEngine_d.lib(Clock.obj) : error LNK2001: 无法解析的外部符号 "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
1>ProgramCommonLibForEngine_d.lib(Profiler.obj) : error LNK2019: 无法解析的外部符号 "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ),该符号在函数 "public: class std::basic_string<char,struct std::char_traits<char>,class std::_DebugHeapAllocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::_DebugHeapAllocator<char> >::erase(unsigned int,unsigned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$_DebugHeapAllocator@D@2@@std@@QAEAAV12@II@Z) 中被引用
1>ProgramCommonLibForEngine_d.lib(WzMemoryTracker.obj) : error LNK2001: 无法解析的外部符号 "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
1>ProgramCommonLibForEngine_d.lib(Clock.obj) : error LNK2001: 无法解析的外部符号 "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
1>ProgramCommonLibForEngine_d.lib(Profiler.obj) : error LNK2001: 无法解析的外部符号 "struct std::_DebugHeapTag_t const std::_DebugHeapTag" (?_DebugHeapTag@std@@3U_DebugHeapTag_t@1@B)
1>ProgramCommonLibForEngine_d.lib(WzMemoryTracker.obj) : error LNK2001: 无法解析的外部符号 "struct std::_DebugHeapTag_t const std::_DebugHeapTag" (?_DebugHeapTag@std@@3U_DebugHeapTag_t@1@B)
1>ProgramCommonLibForEngine_d.lib(Clock.obj) : error LNK2001: 无法解析的外部符号 "struct std::_DebugHeapTag_t const std::_DebugHeapTag" (?_DebugHeapTag@std@@3U_DebugHeapTag_t@1@B)
1>ProgramCommonLibForEngine_d.lib(Profiler.obj) : error LNK2001: 无法解析的外部符号 "__int64 std::_Fpz" (?_Fpz@std@@3_JA)
1>ProgramCommonLibForEngine_d.lib(WzMemoryTracker.obj) : error LNK2001: 无法解析的外部符号 "__int64 std::_Fpz" (?_Fpz@std@@3_JA)
1>ProgramCommonLibForEngine_d.lib(Clock.obj) : error LNK2001: 无法解析的外部符号 "__int64 std::_Fpz" (?_Fpz@std@@3_JA)
1>ProgramCommonLibForEngine_d.lib(Profiler.obj) : error LNK2019: 无法解析的外部符号 "public: void __thiscall std::ios_base::_Addstd(void)" (?_Addstd@ios_base@std@@QAEXXZ),该符号在函数 "protected: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::init(class std::basic_streambuf<char,struct std::char_traits<char> > *,bool)" (?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z) 中被引用
1>ProgramCommonLibForEngine_d.lib(WzMemoryTracker.obj) : error LNK2001: 无法解析的外部符号 "public: void __thiscall std::ios_base::_Addstd(void)" (?_Addstd@ios_base@std@@QAEXXZ)


一堆的std无法解析的外部符号,感觉莫名其妙啊。有的都没显示是在哪个地方被调用,求解
...全文
2089 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
fockwillson 2015-01-20
  • 打赏
  • 举报
回复
无法解析的外部符号 "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ)" 转载请注明出处:http://www.cnblogs.com/royenhome 采用下面的方法。重新编译了一下依赖的库,OK了。   问题描述:       今天用VS2010编译一个在VS2008下Coding的工程的时候,VS给出了一堆链接错误信息,如下图所示:               在ErrorList里面列出了34个链接错误信息,但仔细看的话,其实很多都是重复的,只有两三个外部符号未正确解析,如下:       "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ)       "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xran@_String_base@std@@SAXXZ)                问题分析:         首先,可以确定是程序在Build(构建)过程中,链接静态链接库libprotobuf.lib的时候出现外部符号无法解析的问题,而且可以看出 libprotobuf.lib库中的很多的中间目标文件(Windows下以.obj作后缀名的文件)都对此外部符号存在着引用,但在符号重定位时候却 在全局符号表中找不到引用的符号。                而_Xran和_Xlen这两个符号到底是什么呢,通过google可以大致了解到时string类里面的两个符号,难道问题出在对于string类的引 用么?那么我们可以通过下术的步骤来观察一个引用string头文件的源文件经过IDE的预处理后是怎么样的          1、新建一个名为Test.CPP文件,内容很简单,只是包含一个string头文件,即#include<string>      2、打开VS带的Command Prompt,输入命令 CL /EP Test.cpp > D:\\1.txt       上述命令为使用MSVC的编译器对Test.cpp进行预处理操作,并将内容重定向到1.txt中。           情况一:       如果你用的VS2005或者VS2008下的命令行工具的话,在打开1.txt后其实可以搜索到如下的内容:                     情况2:       如果你使用的是VS2010的话,那么在产生的1.txt中搜索_Xlen与_Xran的话,则为如下的内容:                补充:其中第二个_Xran与_Xlen是在类basic_string中定义的,显然与VS2005与VS2008下产生的不同。               问题总结:        静态链接库libprotobuf.lib在旧版本IDE上编译的,所以string类中符号被解析成形如static void __cdecl _Xlen()         而在高版本的VS2010上string中的_Xlen与_Xran符号则被解析成了__declspec(noreturn) void _Xlen() const        所以才会在链接过程中出现上述开头出现的一堆问题           问题解决:         第一种方法:       重新在高版本的IDE下编译libprotobuf.lib,这种方法最行之有效啦,也很简单        第二种方法:              可以新建一个链接库,导出无法解析的几个符号,并这几个符号实现中重定向到VS2010下预处理后的那几个符号即可。具体参考这个网址:http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/5ac28a31-3339-4db1-90f4-68edad360309 里面的JN123给出的方法: Hi aberazioon, I faced the same problem but in my case, the external libraries were compiled using Studio 2003 and I only had 2 unresolved external symbols: Xran and Xlen. This problem hapens because the library libcpmt.lib (libcpmtd.lib) in MS Visual 2003 and MS Visual 2008 has different prototype definitions for xRan and xLen (MS Visual 200* + command prompt + type the command "dumpbin /ALL libcpmtd.lib" ) In 2003: // 00000018 REL32 00000000 34C ?_Xran@_String_base@std@@QBEXXZ (public: void __thiscall std::_String_base::_Xran(void)const ) // 0000001E REL32 00000000 2DF ?_Xlen@_String_base@std@@QBEXXZ (public: void __thiscall std::_String_base::_Xlen(void)const ) In 2008: // 00000019 REL32 00000000 5CC ?_Xran@_String_base@std@@SAXXZ (public: static void __cdecl std::_String_base::_Xran(void)) // 0000001D REL32 00000000 5C6 ?_Xlen@_String_base@std@@SAXXZ (public: static void __cdecl std::_String_base::_Xlen(void)) To solve the problem I did the following... a bit bizarre but it works for me: (The general idea here is to create a dll / library that exports the unknown symbols and these new methods in the dll will call the new methods behaviour in libcpmt.lib @ 2008) 1) I used MS Visual 2003 pre-processor (type the command "cl /EP <source code_1.cpp>") to get the "String_base" class definition. // Source code_1.cpp #include <string> // end of code_1.cpp In MS Visual 2003, class definition is: class _String_base { public: void _Xlen() const; void _Xran() const; }; 2) According with _Xran and _Xlen definition in 2008, both methods are static. 3) Compile the following source code in 2008. Type the command "cl /D_DLL_EXPORT /EHsc /LD libvisual2003_visual2008.cpp /link". // Source libvisual2003_visual2008.cpp #include <string> namespace std2003_2008 { class _String_base2003_2008 {    public:       __declspec(dllexport) void _Xlen2003_2008(void) const;      __declspec(dllexport) void _Xran2003_2008(void) const; }; }; void std2003_2008::_String_base2003_2008::_Xran2003_2008() const {    std::_String_base::_Xran(); } void std2003_2008::_String_base2003_2008::_Xlen2003_2008() const {     std::_String_base::_Xlen(); } // end of libvisual2003_visual2008.cpp 4) Type the command "dumpbin /ALL libvisual2003_visual2008.dll >1.txt" (MS Visual 2008) to get the public symbols of _Xran2003_2008 and _Xlen2003_2008. // ?_Xlen2003_2008@_String_base2003_2008@std2003_2008@@QBEXXZ // ?_Xran2003_2008@_String_base2003_2008@std2003_2008@@QBEXXZ 5) Re-compile again libvisual2003_visual2008.cpp with following command "cl /D_DLL_EXPORT /EHsc /LD libvisual2003_visual2008.cpp /link /export:?_Xran@_String_base@std@@QBEXXZ=?_Xran2003_2008@_String_base2003_2008@std2003_2008@@QBEXXZ /export:?_Xlen@_String_base@std@@QBEXXZ=?_Xlen2003_2008@_String_base2003_2008@std2003_2008@@QBEXXZ" Here, the new dll will export 2 new symbols (the ones that were unknown in initial compilation) and they will map to the methods _Xlen2003_2008 and _Xran2003_2008. 6) If you dump the public symbols of the new dll (step 5), you will get the following: // 1 0 00001010 ?_Xlen2003_2008@_String_base2003_2008@std2003_2008@@QBEXXZ // 2 1 00001010 ?_Xlen@_String_base@std@@QBEXXZ // 3 2 00001000 ?_Xran2003_2008@_String_base2003_2008@std2003_2008@@QBEXXZ // 4 3 00001000 ?_Xran@_String_base@std@@QBEXXZ 7) Re-compile the program again with the new "libvisual2003_visual2008.lib" library. 8) To run the application don't forget the "libvisual2003_visual2008.dll". Greetings JN123 @ Portugal Friday, August 22, 2008 1:30 PM
赵4老师 2013-12-20
  • 打赏
  • 举报
回复
_BADOFF _Xlen ……
Sanda_Chang 2013-12-19
  • 打赏
  • 举报
回复
引用 9 楼 zhao4zhong1 的回复:
[quote=引用 8 楼 sx5486510 的回复:] [quote=引用 7 楼 zhao4zhong1 的回复:] VC6: 工程、设置、C/C++、分类:Preprocessor、附加包含路径:填写附加头文件所在目录 逗号间隔多项 工程、设置、Link、分类:Input、附加库路径:填写附加依赖库所在目录 分号间隔多项 工程、设置、Link、分类:Input、对象/库模块:填写附加依赖库的名字.lib 空格间隔多项 VS20xx: 项目、属性、C/C++、附加包含目录:填写附加头文件所在目录 分号间隔多项 项目、属性、链接器、常规、附加库目录:填写附加依赖库所在目录 分号间隔多项 项目、属性、链接器、输入、附加依赖项:填写附加依赖库的名字.lib 空格或分号间隔多项
每次都说点这网上随便一搜一大把的东西,能不能说一下怎么通过这些错误提示,找到需要连接的库[/quote] 将错误信息中出现的标识符放在google里面搜一下,看其在哪个.lib中,然后在本地硬盘上搜索该.lib,如果没有,在网上搜索相关库或模块下载安装,然后将其所在目录填写到“附加依赖库所在目录”中,将其名字添加到“附加依赖库”中,重新连接。[/quote] 请问赵老师“错误信息中出现的标识符”指的是哪个?
zhctj159 2013-08-09
  • 打赏
  • 举报
回复
引用 15 楼 sx5486510 的回复:
[quote=引用 14 楼 zhctj159 的回复:] [quote=引用 11 楼 sx5486510 的回复:] [quote=引用 10 楼 zhctj159 的回复:] 大概是头文件和库文件不对应、、、ios_base都有问题了、、, 你引用的是C++的运行库,但是头文件里又加了extern "C" ..或者源文件根本就是C文件而不是cpp文件 不知道我说对了没?
不知道你说的对不对 有没有理论依据?[/quote]我说得一般可比教科书 呵呵[/quote] ........[/quote]我到底说对了没?没对的话咱可以进一步讨论
cc___999 2013-08-09
  • 打赏
  • 举报
回复
引用 14 楼 zhctj159 的回复:
[quote=引用 11 楼 sx5486510 的回复:] [quote=引用 10 楼 zhctj159 的回复:] 大概是头文件和库文件不对应、、、ios_base都有问题了、、, 你引用的是C++的运行库,但是头文件里又加了extern "C" ..或者源文件根本就是C文件而不是cpp文件 不知道我说对了没?
不知道你说的对不对 有没有理论依据?[/quote]我说得一般可比教科书 呵呵[/quote] ........
zhctj159 2013-08-08
  • 打赏
  • 举报
回复
引用 11 楼 sx5486510 的回复:
[quote=引用 10 楼 zhctj159 的回复:] 大概是头文件和库文件不对应、、、ios_base都有问题了、、, 你引用的是C++的运行库,但是头文件里又加了extern "C" ..或者源文件根本就是C文件而不是cpp文件 不知道我说对了没?
不知道你说的对不对 有没有理论依据?[/quote]我说得一般可比教科书 呵呵
文修 2013-08-08
  • 打赏
  • 举报
回复
一般来说VC出现“无法解析的外部符号”绝大多数是由于缺少相关的库文件造成的,你可以检查一下你的程序,看看是否缺少依赖项。
sunfish_iris 2013-08-08
  • 打赏
  • 举报
回复
cc___999 2013-08-08
  • 打赏
  • 举报
回复
引用 10 楼 zhctj159 的回复:
大概是头文件和库文件不对应、、、ios_base都有问题了、、, 你引用的是C++的运行库,但是头文件里又加了extern "C" ..或者源文件根本就是C文件而不是cpp文件 不知道我说对了没?
不知道你说的对不对 有没有理论依据?
cc___999 2013-08-06
  • 打赏
  • 举报
回复
引用 2 楼 mujiok2003 的回复:
[quote=引用 1 楼 mujiok2003 的回复:]
#include <iosteram>
#include <string>
要只包含
<iosfwd>
要->不要[/quote]什么?里面貌似加这些头文件 我再找找
max_min_ 2013-08-06
  • 打赏
  • 举报
回复
引用 4 楼 sx5486510 的回复:
[quote=引用 3 楼 max_min_ 的回复:] 这个度娘知道的!

一般出现lnk2019错误都是库文件没添加造成的。
项目--》属性--》配置属性--》链接器-》输入--》附加依赖项
在其中加入所需库文件,同时在“链接器--》常规--》附加库目录”中填入相应库名。
这样应该就可以
这个我知道 就是不知道是加哪个库[/quote] 将c文件名改为.cpp,或者将c++文件名改为.c 重新编译试试
cc___999 2013-08-06
  • 打赏
  • 举报
回复
引用 3 楼 max_min_ 的回复:
这个度娘知道的!

一般出现lnk2019错误都是库文件没添加造成的。
项目--》属性--》配置属性--》链接器-》输入--》附加依赖项
在其中加入所需库文件,同时在“链接器--》常规--》附加库目录”中填入相应库名。
这样应该就可以
这个我知道 就是不知道是加哪个库
max_min_ 2013-08-06
  • 打赏
  • 举报
回复
这个度娘知道的!

一般出现lnk2019错误都是库文件没添加造成的。
项目--》属性--》配置属性--》链接器-》输入--》附加依赖项
在其中加入所需库文件,同时在“链接器--》常规--》附加库目录”中填入相应库名。
这样应该就可以
mujiok2003 2013-08-06
  • 打赏
  • 举报
回复
引用 1 楼 mujiok2003 的回复:
#include <iosteram>
#include <string>
要只包含
<iosfwd>
要->不要
mujiok2003 2013-08-06
  • 打赏
  • 举报
回复
#include <iosteram>
#include <string>
要只包含
<iosfwd>
zhctj159 2013-08-06
  • 打赏
  • 举报
回复
大概是头文件和库文件不对应、、、ios_base都有问题了、、, 你引用的是C++的运行库,但是头文件里又加了extern "C" ..或者源文件根本就是C文件而不是cpp文件 不知道我说对了没?
赵4老师 2013-08-06
  • 打赏
  • 举报
回复
引用 8 楼 sx5486510 的回复:
[quote=引用 7 楼 zhao4zhong1 的回复:] VC6: 工程、设置、C/C++、分类:Preprocessor、附加包含路径:填写附加头文件所在目录 逗号间隔多项 工程、设置、Link、分类:Input、附加库路径:填写附加依赖库所在目录 分号间隔多项 工程、设置、Link、分类:Input、对象/库模块:填写附加依赖库的名字.lib 空格间隔多项 VS20xx: 项目、属性、C/C++、附加包含目录:填写附加头文件所在目录 分号间隔多项 项目、属性、链接器、常规、附加库目录:填写附加依赖库所在目录 分号间隔多项 项目、属性、链接器、输入、附加依赖项:填写附加依赖库的名字.lib 空格或分号间隔多项
每次都说点这网上随便一搜一大把的东西,能不能说一下怎么通过这些错误提示,找到需要连接的库[/quote] 将错误信息中出现的标识符放在google里面搜一下,看其在哪个.lib中,然后在本地硬盘上搜索该.lib,如果没有,在网上搜索相关库或模块下载安装,然后将其所在目录填写到“附加依赖库所在目录”中,将其名字添加到“附加依赖库”中,重新连接。
cc___999 2013-08-06
  • 打赏
  • 举报
回复
引用 7 楼 zhao4zhong1 的回复:
VC6: 工程、设置、C/C++、分类:Preprocessor、附加包含路径:填写附加头文件所在目录 逗号间隔多项 工程、设置、Link、分类:Input、附加库路径:填写附加依赖库所在目录 分号间隔多项 工程、设置、Link、分类:Input、对象/库模块:填写附加依赖库的名字.lib 空格间隔多项 VS20xx: 项目、属性、C/C++、附加包含目录:填写附加头文件所在目录 分号间隔多项 项目、属性、链接器、常规、附加库目录:填写附加依赖库所在目录 分号间隔多项 项目、属性、链接器、输入、附加依赖项:填写附加依赖库的名字.lib 空格或分号间隔多项
每次都说点这网上随便一搜一大把的东西,能不能说一下怎么通过这些错误提示,找到需要连接的库
赵4老师 2013-08-06
  • 打赏
  • 举报
回复
VC6: 工程、设置、C/C++、分类:Preprocessor、附加包含路径:填写附加头文件所在目录 逗号间隔多项 工程、设置、Link、分类:Input、附加库路径:填写附加依赖库所在目录 分号间隔多项 工程、设置、Link、分类:Input、对象/库模块:填写附加依赖库的名字.lib 空格间隔多项 VS20xx: 项目、属性、C/C++、附加包含目录:填写附加头文件所在目录 分号间隔多项 项目、属性、链接器、常规、附加库目录:填写附加依赖库所在目录 分号间隔多项 项目、属性、链接器、输入、附加依赖项:填写附加依赖库的名字.lib 空格或分号间隔多项

64,651

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧