1

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?

paul23
  • 8,799
  • 12
  • 66
  • 149
  • You don't need just directories for boost::filesystem, you also need to link against the boost_filesystem library. Do you have that set? (And Qt has file/path management functions, you should probably use those in Qt projects.) – Mat Feb 08 '12 at 18:52
  • @Mat What you mean with that? If you mean that I have to include the actual library in the additional dependencies part.. How do I know the actual library - and more importantly, why does it correctly recognize the library when creating a native application? - I'm using boost in a lot of the main program, and I'm now trying to couple the main program together with the interface (written in qt). – paul23 Feb 08 '12 at 18:57

2 Answers2

2

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.

Community
  • 1
  • 1
Dave Mateer
  • 17,608
  • 15
  • 96
  • 149
  • Wait that means I also have to manually compile the qt sdk? - Which probably also means the add in won't work? EDIT: I changed the project options from the project to use wchar_t as build in type - seems to work now. – paul23 Feb 08 '12 at 19:10
  • No, you don't necessarily have to recompile Qt. It is just that *all* incorporated libraries have to match. It looks like in your case changing your current project was enough. Sometimes this creates a daisy chain effect, and the easiest solution is to fix the odd-ball, which is Qt in this case. – Dave Mateer Feb 08 '12 at 19:34
0

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

Marko
  • 20,385
  • 13
  • 48
  • 64