PDA

View Full Version : Problem porting to VC2005



Khal Drogo
15th February 2008, 16:58
Greetings.

I had a project made under VC2003 with Qt 4.3.3, and i tried to port it to VC2005.

I am using something like:

HWND appWindow = FindWindow(NULL, static_cast<LPCWSTR>(title.toStdWString().c_str()));


The above code worked beautifully under VS2003, but it gives the following linking error under VC2005. :

Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __thiscall QString::toStdWString(void)const " (__imp_?toStdWString@QString@@QBE?AV?$basic_string @_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@ XZ) referenced in function "private: void __thiscall test::nextWindow(void)" (?nextWindow@test@@AAEXXZ) test.obj


Please give me some ideas as to why this might happen.

jpn
15th February 2008, 17:05
Is this another Qt installation too? Looks like your Qt was built without STL support.

Khal Drogo
15th February 2008, 17:12
That was my first idea, but it isn't so, title.toStdString() works perfectly, but i cannot convert it to whatever FindWindow needs.

jpn
15th February 2008, 20:48
So, what does "porting from vs2003 to vs2005" mean in this case? Did you simply open the old .vcproj in vs2005 or have you maintained a .pro file?

Khal Drogo
18th February 2008, 07:17
It means, i opened the solution file and let VS convert my project.

jpn
18th February 2008, 09:38
What if you create a proper .pro file and let qmake generate a Visual Studio project for you?

ChristianEhrlicher
19th February 2008, 06:26
Or do a clean rebuild instead 'just opening and compiling'

VlJE
26th March 2008, 14:09
Hi! I have the same problem with QString::toStdWString().
My project is originally VS2005-QT4.2 Project. I have had no Problem wether with STL nore with QT, before I tried toStdWString(). Clean/Rebuild/reimport from PRO does not help. Any constructiv idea?

VlJE
26th March 2008, 15:13
The solution found in the other thread:
Project-Property
wchar_t as Built_in Type -> set to False.

CrackedMind
27th March 2008, 09:53
HWND appWindow = FindWindow(NULL, static_cast<LPCWSTR>(title.toStdWString().c_str()));
you can replace this with


HWND appWindow = FindWindow(NULL, (wchar_t*)title.utf16());