Question

Hi I'm using visual studio 2010.. And I added the add in for Qt as well as manually build the last boost package. Now I started a new project, a qt window application.

There I used the following code:

#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();
}

However this seems to fail.. While when I use EXACT THE SAME code but instead don't use the qt template it works. The exact errors are as follow:

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)

I tried to look into the obvious settings; but in the project properties the boost library directory is still located under VC++ directories -> library directories

What is causing this? How do I solve this?

Was it helpful?

Solution

I'm guessing you might be seeing the behavior described here:

Qt and MSVC use opposite default for the "wchar_t as built in type" option. This means you can usually compile fine, but it fails at link time, which seems to be what you are seeing. We had this problem with using some third party libraries from Qt. Our solution was to compile Qt with the same option that MSVC uses by default, i.e. /Zc:wchar_t.

FWIW, this is supposed to be fixed in Qt5.

OTHER TIPS

put /Zc:wchar_t in additional options in compiler options. That worked for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top