c++ - 使用 qt 模板时未解析的外部?

标签 c++ visual-studio-2010 qt linker boost-filesystem

您好,我正在使用 visual studio 2010.. 我为 Qt 添加了插件,并手动构建了最后一个增强包。现在我开始了一个新项目,一个 qt 窗口应用程序。

我使用了下面的代码:

#include <boost/filesystem.hpp>

int main(int argc, char *argv[])
{
    boost::filesystem::path p("c:/test/test.gmx");
    boost::filesystem::path ext(p.extension());
    boost::filesystem::path name(p.leaf().replace_extension(""));
    //QApplication a(argc, argv);
    //MainInterface w;
    //w.show();
    //return a.exec();
}

然而,这似乎失败了。虽然当我使用完全相同的代码但不使用它工作的 qt 模板时。具体错误如下:

1>main.obj : error LNK2019: unresolved external symbol "private: static class std::codecvt<unsigned short,char,int> const * & __cdecl boost::filesystem3::path::wchar_t_codecvt_facet(void)" (?wchar_t_codecvt_facet@path@filesystem3@boost@@CAAAPBV?$codecvt@GDH@std@@XZ) referenced in function "public: static class std::codecvt<unsigned short,char,int> const & __cdecl boost::filesystem3::path::codecvt(void)" (?codecvt@path@filesystem3@boost@@SAABV?$codecvt@GDH@std@@XZ)
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl boost::filesystem3::path_traits::convert(char const *,char const *,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &,class std::codecvt<unsigned short,char,int> const &)" (?convert@path_traits@filesystem3@boost@@YAXPBD0AAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@ABV?$codecvt@GDH@5@@Z) referenced in function "void __cdecl boost::filesystem3::path_traits::dispatch<class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &,class std::codecvt<unsigned short,char,int> const &)" (??$dispatch@V?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@path_traits@filesystem3@boost@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@4@ABV?$codecvt@GDH@4@@Z)

我试图查看明显的设置;但在项目属性中,boost 库目录仍位于 VC++ 目录下 -> 库目录

这是什么原因造成的?我该如何解决这个问题?

最佳答案

我猜您可能会看到此处描述的行为:

Qt 和 MSVC 对“wchar_t as built in type”选项使用相反的默认值。这意味着您通常可以正常编译,但它在链接时失败,这似乎就是您所看到的。我们在使用 Qt 的一些第三方库时遇到了这个问题。我们的解决方案是使用 MSVC 默认使用的相同选项编译 Qt,即 /Zc:wchar_t

FWIW,这应该是 fixed in Qt5 .

关于c++ - 使用 qt 模板时未解析的外部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9199535/

相关文章:

c++ - Codelite 调试器错误 : Failed to locate gdb! 在 '/usr/bin/gdb'

c++ - Unordered_map 产生二级键

asp.net - 如何在 Visual Studio 2010 中调试 ASPNET 工作进程的转储文件?

c++ - 在 Python 中使用自定义 Qt 子类

c++ - 是否有任何教程可以帮助精通 c++ 的程序员学习 c?

c++ - 在链表前面插入节点

c# - 使用一个 Windows 窗体 - Visual Studios c#

linux - 设置 ostream linux/visual studio 的指数字段的宽度

linux - QIBASE 的问题(firebird + Ubuntu)

c++ - Qt Signal Slots 类作用域类型