解决“局部定义的符号”和“未解析的外部符号”它源自.lib文件 [英] Solving "locally defined symbol" and "unresolved external symbol" that originates from the .lib files

查看:213
本文介绍了解决“局部定义的符号”和“未解析的外部符号”它源自.lib文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Windows 7 64位上使用Visual C ++ 2010上的开源库GDCM编译我的项目。我在我的项目中包括了必需的.lib文件(gdcmDSED.lib和gdcmMSFF.lib),但是,编译器抱怨超过100个未解决的外部错误。但我看到一些模式的错误。这里:

  1> gdcmDSED.lib(gdcmSequenceOfItems.obj):warning LNK4049:本地定义的符号?? 1?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ QAE @ XZ(public:__thiscall std :: basic_string< char,struct std :: char_traits< char>,class std :: allocator< char>> ::〜basic_string< char,struct std :: char_traits< char>,class std :: allocator< char>>(void))imported 
...

1> gdcmMSFF.lib(gdcmCurve.obj):error LNK2001:未解析的外部符号__declspec(dllimport)public:__thiscall std :: basic_string< char,struct std :: char_traits< char>,class std :: allocator< char>> :: basic_string< char,struct std :: char_traits< char>,class std :: allocator< char>>(class std :: basic_string< char,struct std :: char_traits< char>,class std :: allocator< char> const&)(__imp _ ?? 0?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ @ std @@ QAE @ ABV01 @ @Z)
1> gdcmDSED.lib(gdcmCSAHeader.obj):error LNK2001:未解析的外部符号__declspec(dllimport)public:__thiscall std :: basic_string< char,struct std :: char_traits< char>,class std :: allocator< char> > :: basic_string< char,struct std :: char_traits< char>,class std :: allocator< char> >(std :: basic_string< char,struct std :: char_traits< char>,class std :: allocator< char>>>>>>>>>><>)(__imp _ ?? 0?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ QAE @ ABV01 @@ Z)

这是从总共100个警告和2个错误。这是为了更好地澄清。我可以看到编译器抱怨所有这些警告和错误,关于本地定义的符号和未解决的外部符号。 此外,错误似乎源自.lib文件本身(不是从[我的项目的名称] .obj),如上所示。



我试过包括库中的所有.lib文件,但这似乎不解决它更糟糕的是,编译器输出更多的相同的警告和错误。



解决方案

在互联网上找到这个问题:我在这里忘记了什么?



这是否响铃?

p>请参阅: http://www.creatis.insa-lyon .fr / pipermail / dcmlib / 2007-April.txt


I am trying to compile my project with an open source library GDCM on Visual C++ 2010 on Windows 7 64 bits. I have included required .lib files (gdcmDSED.lib and gdcmMSFF.lib) in my project, however, the compiler complains back more than 100 unresolved external errors. But I see some patterns in the errors. Here:

1>gdcmDSED.lib(gdcmSequenceOfItems.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported
...
...
1>gdcmMSFF.lib(gdcmCurve.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z)
1>gdcmDSED.lib(gdcmCSAHeader.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z)

These are 1 warning and 2 errors from total 100. This is for better clarification. I can see that the compiler complains all these warnings and errors, either about "locally defined symbol" and "unresolved external symbol". Moreover, it seems that the error originates from the .lib files themselves (not from [my project's name].obj), as you can see above.

I have tried include all the .lib files from the library, but that does not seem to solve it. Worse, the compiler outputs more of the same warnings and errors.

Am I forgetting something here? What must I do in order to solve this problem?

解决方案

Found this on the internet : The problems disappear when creating the gdcm DLL with the BUILD_SHARED_LIBS ON.

Does this ring a bell ?

see: http://www.creatis.insa-lyon.fr/pipermail/dcmlib/2007-April.txt

这篇关于解决“局部定义的符号”和“未解析的外部符号”它源自.lib文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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