Неопределенная ссылка на `__imp_cocreateinstance 'на Mingw-W64 [дублировать]C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Неопределенная ссылка на `__imp_cocreateinstance 'на Mingw-W64 [дублировать]

Сообщение Anonymous »

Я попробовал приложение Compile win32 с Mingw-W64.

, но оно повышает ошибку
undefined reference to __imp_CoCreateInstance' on mingw-w64< /code> < /code>. < /p>
My Mingw-w64, установленная в каталоге C: \ mingw64.

и заданные параметры для компиляции.g++ -L C:\mingw64\x86_64-w64-mingw32\lib -lole32 hello.cpp -o hello
< /code>
Как я могу исправить эту ошибку?#include
#include
#include
#include
#include

#include
#include
#include

HRESULT InitializeUIAutomation(IUIAutomation **ppAutomation)
{
return CoCreateInstance(CLSID_CUIAutomation, NULL,
CLSCTX_INPROC_SERVER, IID_IUIAutomation,
reinterpret_cast(ppAutomation));
}

void show_error(HRESULT hr)
{
if (hr != S_OK)
{
std::string s = std::system_category().message(hr);
const char *err = s.c_str();
printf("%s\n", err);
}
}

int main()
{
printf("Hello world from windows2\n");
IUIAutomation **ppAutomation;
IUIAutomation *pAutomation;
IUIAutomationElement *root;
IUIAutomationElement *start_button;
IUIAutomationElement3 *start_button3;
IUIAutomationCondition *start_button_cond;
VARIANT start_button_v;
wchar_t *start_button_autoid = L"StartButton";

InitializeUIAutomation(ppAutomation);
pAutomation = *ppAutomation;
HRESULT hr = pAutomation->GetRootElement(&root);
show_error(hr);
start_button_v.vt = VT_BSTR;
start_button_v.bstrVal = start_button_autoid;
pAutomation->CreatePropertyCondition(UIA_AutomationIdPropertyId, start_button_v, &start_button_cond);
hr = root->FindFirst(TreeScope_Descendants, start_button_cond, &start_button);
show_error(hr);
start_button3 = reinterpret_cast(start_button);
start_button3->ShowContextMenu();

}


Подробнее здесь: https://stackoverflow.com/questions/797 ... -mingw-w64
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»