PDA

View Full Version : Finding window, linker error



Khal Drogo
14th March 2008, 11:23
Greetings.

I used the following code with VS2003 and Qt 4.3.2 with success:


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

I now ported to VS2005 and Qt 4.4.0 and i receive the following linker error:

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)

Could you shed some light on what could be the problem?

Thank you.

jpn
14th March 2008, 11:31
Looks like your Qt was compiled without STL support.

Khal Drogo
14th March 2008, 11:38
Don't believe thats the case.


std::string x = title.toStdString();

The above works just fine, but FindWindow needs a widestring param.

jpn
14th March 2008, 11:53
Can you find a "QString::toStdWString" symbol when you open up QtCore4.dll in Dependency Walker?

jpn
14th March 2008, 12:00
Do you have something like "treat wchar as internal type" enabled in your project settings?

Khal Drogo
14th March 2008, 12:06
Yes, i can find it in Dependency Walker and yes, Treat wchar_t as Built_in Type is set to Yes.

jpn
14th March 2008, 12:45
What happens if you disable it?

Khal Drogo
14th March 2008, 12:49
That seemed to do the trick. Thanks very much for helping me hunt this down.