title: How to declare and link to RoInitialize,RoUninitialize,RoGetActivationFactory and HSTRING Functions in Mingw Gcc
body: <p>UPDATED: Added what <code>RoInitialize</code> looks like in roapi.h</p>
  <p>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).</p>
  <p>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.</p>
  <p>What I need at this point is a way to call the Windows API Functions <code>RoInitialize</code>, <code>RoUnitialize</code>, <code>RoGetActivationFactory</code> and the <code>HSTRING</code> Functions <code>WindowsCreateString</code>, <code>WindowsDuplicateString</code>, <code>WindowsDeleteString</code>.</p>
  <p>I tried compiling this program in G++ but got the error</p>
  <pre><code>extern &quot;C&quot;{
  __declspec(dllimport)int __stdcall RoInitialize(int);
  }
  int main(){
      RoInitialize(1);
  }
  </code></pre>
  <p>I tried to compile but got:</p>
  <pre><code>c:\Users\jrb\Desktop&gt;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
  </code></pre>
  <p>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 requires <code>LoadLibrary</code>/<code>GetProcAddress</code> I would still be ok with that</p>
  <p>Update: Here is what <code>RoInitialize</code> looks like in the header roapi.h</p>
  <pre><code>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
  </code></pre>