Ped*_*dro 7 c++ qt boost linker-errors visual-studio-2010
当我在我的c ++项目中一起使用Qt(v4.7.4)和Boost(尝试v1.47和v1.48)时,我得到一个由包含的类引起的链接器错误<boost\filesystem.hpp>.我刚刚设置了Qt,在代码工作之前没有任何问题.
这是错误消息:
... obj:错误LNK2001:未解析的外部符号"private:static class std :: codecvt const*&__cdecl boost :: filesystem3 :: path :: wchar_t_codecvt_facet(void)"(?wchar_t_codecvt_facet @ path @ filesystem3 @ boost @@ CAAAPBV ?$ @的codecvt GDH @ STD @@ XZ)
... obj:错误LNK2001:未解析的外部符号"void __cdecl boost :: filesystem3 :: path_traits :: convert(char const*,char const*,class std :: basic_string,class std :: allocator>&,class std: :codecvt const&)"(?convert @ path_traits @ filesystem3 @ boost @@ YAXPBD0AAV?$ basic_string @ GU?$ char_traits @ G @ std @@ V?$ allocator @ G @ 2 @@ std @@ ABV?$ codecvt @ GDH @ @@ 5 Z)
... obj:错误LNK2001:未解析的外部符号"void __cdecl boost :: filesystem3 :: path_traits :: dispatch(类boost :: filesystem3 :: directory_entry const&,class std :: basic_string,class std :: allocator>&, class std :: codecvt const&)"(?dispatch @path_traits @ filesystem3 @ boost @@ YAXABVdirectory_entry @ 23 @ AAV?$ basic_string @ GU?$ char_traits @ G @ std @@ V?$ allocator @ G @ 2 @@ std @@ ABV?$ @的codecvt GDH @ 6 @@ Z)
... obj:错误LNK2001:未解析的外部符号"void __cdecl boost :: filesystem3 :: path_traits :: convert(unsigned short const*,unsigned short const*,class std :: basic_string,class std :: allocator>&,class std :: codecvt const&)"(?convert @ path_traits @ filesystem3 @ boost @@ YAXPBG0AAV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ ABV?$的codecvt @ GDH @ @@ 5 Z)
... exe:致命错误LNK1120:4个未解析的外部
编辑:
在这里,我发现有人遇到这个问题得出这个结论:
这确实是一个Qt问题.使用wchar_t作为本机类型,您必须使用相同的编译器开关重新编译Qt.跟踪器中甚至还有一个错误:https://bugreports.qt.io/browse/QTBUG-9617
通常,您必须非常小心,不要在项目中混合使用wchar_t编译器设置,因为它们将变得不兼容.
所以我重新编译了Qt设置/Zc:wchar_t,但它没有显示任何效果.我仍然得到同样的错误.
我认为你是在正确的轨道,但听起来你-Zc:wchar_t没有"坚持".我们必须做同样的事情才能让Qt对Google Breakpad和ICU库感到满意.我们更改了/Zc:wchar_t设置(QT_SOURCE)\mkspecs\win32-msvc2008\qmake.conf并从源代码编译了Qt,之后一切正常.
在构建使用Qt和Boost的项目时,您应该在编译器输出中看到此选项.就像是:
cl -c -nologo -Zm200 -Zc:wchar_t ... (etc.)
Run Code Online (Sandbox Code Playgroud)
如果您已经建立Qt的没有这个选项,你可能需要做一个make confclean第一,以确保一切真的得到新的设置重建.