使用qt模板时无法解决外部问题
Unresolved external when using qt template?
嗨,我使用的是visual studio 2010。我添加了Qt的外接程序,并手动构建了最后一个boost包。现在我开始了一个新项目,一个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和/Zc:wchar_t-==我想炸毁世界
Qt和MSVC对"wchar_t as build-in type"选项使用相反的默认值。这意味着您通常可以很好地编译,但它在链接时失败,这似乎就是您所看到的。我们在使用Qt的一些第三方库时遇到了这个问题。我们的解决方案是使用MSVC默认使用的相同选项(即/Zc:wchar_t
)编译Qt。
FWIW,这应该在Qt5中被固定。
将/Zc:wchar_t
放入编译器选项中的其他选项中。这对我很有效。
相关文章:
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- 节俭并发:未解决的外部问题
- 未解决的外部链接问题
- 使用 Git 处理 C++ Visual Studio 2019 解决方案的外部依赖项源代码管理的最佳方法是什么?
- Visual Studio 2017 中的 QtMetaObject 未解决的外部错误
- 在Embarcadero C++ Builder中生成的DLL未解决的外部链接错误
- 解释未解决的外部C++
- 矛盾的未解决的外部符号+未使用的库与VS2017和FFMPEG 4
- 函数路径追加上未解决的外部符号错误
- Lapack函数DGTSV通过C /Visual Studio提供未解决的外部符号
- 运算符过载上未解决的外部符号
- qfilesystemwatcher未解决的外部
- C 未解决的外部符号(公共静态INT)
- MIDL COM库中未解决的外部符号
- 单一实例对象的未解决外部符号链接错误
- 导出类静态常量的未解决外部符号链接错误(仅限某些项目)
- C++非常简单的未解决外部
- 无法解决外部符号错误
- 使用qt模板时无法解决外部问题
- 如何纠正不一致的未解决外部错误