如何在Mingw Gcc中声明并链接到RoInitialize,RoUninitialize,RoGetActivationFactory和HSTRING函数 [英] How to declare and link to RoInitialize,RoUninitialize,RoGetActivationFactory and HSTRING Functions in Mingw Gcc

查看:163
本文介绍了如何在Mingw Gcc中声明并链接到RoInitialize,RoUninitialize,RoGetActivationFactory和HSTRING函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:添加了roInitialize在roapi.h中的外观

UPDATED: Added what RoInitialize looks like in roapi.h

我正在编写一个纯C ++ 11 WinRT库。我不使用WRL或C ++ / CX(显然,如果我想要纯C ++ 11)。

I am in the process of writing a pure C++11 WinRT library. I do not use WRL or C++/CX(Obviously if I want pure C++11).

我可以将代码编译并在MSVC上运行,但是我想要看看是否可以获取代码以在Mingw Gcc上编译和运行。具体来说,我使用的是从nuwen.net获得的Gcc 4.7.2。

I got my code to compile and run on MSVC, but I want to see if I can get the code to compile and run on Mingw Gcc. Specifically I am using Gcc 4.7.2 obtained from nuwen.net.

此时,我需要一种方法来调用Windows API函数RoInitialize RoUnitialize RoGetActivationFactory和HSTRING函数WindowsCreateString,WindowsDuplicateString,WindowsDeleteString。

What I need at this point is a way to call the Windows API Functions RoInitialize RoUnitialize RoGetActivationFactory and the HSTRING Functions WindowsCreateString, WindowsDuplicateString, WindowsDeleteString.

我尝试在G ++中编译此程序,但出现错误

I tried compiling this program in G++ but got the error

extern "C"{
__declspec(dllimport)int __stdcall RoInitialize(int);
}
int main(){
    RoInitialize(1);
}

我尝试编译,但是得到了

I tried to compile, but got

c:\Users\jrb\Desktop>g++ gccwinrt.cpp
C:\Users\jrb\AppData\Local\Temp\ccy7y1V9.o:gccwinrt.cpp:(.text+0x1e): undefined
reference to `_imp__RoInitialize@4'
collect2.exe: error: ld returned 1 exit status

如果有人可以指出正确的方向,说明如何声明这些函数以及需要链接的库,将不胜感激。即使需要LoadLibrary / GetProcAddress,我仍然可以接受

If anybody can point me in the right direction on how to declare these functions and what libraries I need to link to, I would appreciate it. Even if it required LoadLibrary/GetProcAddress I would still be ok with that

更新:这是RoInitialize在标题roapi.h中的样子

Update: Here is what RoInitialize looks like in the header roapi.h

ROAPI
_Check_return_
HRESULT
WINAPI
RoInitialize(
    _In_ RO_INIT_TYPE initType
);

ROAPI is just a define for __declspec(dllimport)
_Check_return_ is part of SAL (Secure Annotations Language?)
HRESULT maps to int32
WINAPI is a define for __stdcall
RO_INIT_TYPE is an enumeration so int should cover it


推荐答案

这些函数的导入库为 runtimeobject.lib (MSDN文档未提及)。可以在Windows 8的Windows SDK中找到它。

The import library for these functions is runtimeobject.lib (which the MSDN documentation fails to mention). It can be found in the Windows SDK for Windows 8.

这篇关于如何在Mingw Gcc中声明并链接到RoInitialize,RoUninitialize,RoGetActivationFactory和HSTRING函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆