解决“局部定义的符号”问题和“未解析的外部符号”源自 .lib 文件

发布于 2024-10-13 08:16:58 字数 1878 浏览 2 评论 0原文

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

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)

总共 100 个错误中有 1 个警告和 2 个错误。这是为了更好地说明。 我可以看到编译器抱怨所有这些警告和错误,要么是关于“本地定义的符号”和“未解析的外部符号”。而且,错误似乎源自 .lib 文件本身(而不是来自[我的项目名称].obj),如上所示。

我尝试包含库中的所有 .lib 文件,但这似乎并不能解决问题。更糟糕的是,编译器会输出更多相同的警告和错误。

我在这里忘记了什么吗?为了解决这个问题我必须做什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

羁拥 2024-10-20 08:16:58

在互联网上找到了这个:使用以下命令创建 gdcm DLL 时问题消失了
BUILD_SHARED_LIBS 打开。

这是否敲响了警钟?

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

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

我的鱼塘能养鲲 2024-10-20 08:16:58

basic_string 需要 #include, 你尝试过吗?

That basic_string needs #include <string>, have you tried that?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文