Reputation: 71
My link error:
Qt\Tools\mingw530_32\i686-w64-mingw32\include\comutil.h:278: erreur : undefined reference to `_com_util::ConvertStringToBSTR(char const*)@4'
Actually in .pro file:
LIBS += -lws2_32 -lwbemuuid -lole32
Which lib to add? lib comsuppw? Is it available for mingw?
Qt 5.10 - mingw32
Upvotes: 3
Views: 1925
Reputation: 71
The problem was due to the function bstr_t() in:
hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM Win32_Process"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
The solution is to create BSTR strings directly:
BSTR bstr_wql = SysAllocString(L"WQL" );
BSTR bstr_sql = SysAllocString(L"SELECT * FROM Win32_Process" );
then use them,
hres = pSvc->ExecQuery(bstr_wql, bstr_sql, ...);
Don't forget to free the allocated memory strings after the query:
SysFreeString(bstr_wql);
SysFreeString(bstr_sql);
The linker is satisfied.
Upvotes: 3