Using MIDL with MinGW

I have an idl file. I have MinGW 5.3 and I have MIDL compiler installed with Windows SDK. I am unable to use this combo, can someone assist me?

In the following, "current_folder" is the current working folder where ABC.idl is located.
g++ location is "C:\Program Files\mingw-w64\x86_64-5.3.0-posix-seh-rt_v4-rev0\mingw64\bin\g++.exe".
/cpp_cmd g++ tells MIDL to use g++ instead of cl.exe for preprocessing.
/cpp_opt "-E -I"current_folder"" tells MIDL to send "-E -I"current_folder"" options to g++. (-E is for preproccesing)
======================================================
"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\midl" /win64 /cpp_cmd g++ /cpp_opt "-E -I"current_folder"" ABC.idl

Microsoft (R) 32b/64b MIDL Compiler Version 8.00.0603
Copyright (c) Microsoft Corporation. All rights reserved.
64 bit Processing .\ABC.idl
g++: warning: current_folder\ABC.idl: linker input file unused because linking not done ABC.idl(1) : error MIDL2183 : unexpected end of file found
Last edited on
I've never been successful in creating any type of COM component using MinGW hazdazzler. And I've tried hard. What I've always attempted was the creation of 'In Process Servers', and these can have MIDL created Type Libraries embedded in them as a resource.

Could you elaborate a bit more on the big picture of what you are trying to accomplish? Don't know if I can help, but I'll try. I have worked extensively with MIDL, COM components, Type Libraries, MS VC, and GCC.
Thank you for your reply. I'll try to explain

I have an .idl file, .cpp/.hpp files and .xla files as inputs. I intend to use these to create a.dll file that I can use with .xla file in Excel.

I have been using Visual Studio with Windows SDK, to compile my .idl file (using midl) using cl.exe as my preprocessor. Once I preprocess my idl file (1st step), I again use cl.exe and link.exe (part of Visual Studio) to compile and link the already available .cpp/.hpp files and .obj files respectively to get a .dll as the end-result. I need to use this .dll with already available .xla file in Excel.

Since Visual Studio is not free, I thought may be I can replace cl.exe invocations with g++ (part of MinGW which is free) invocations. MIDL needs a C preprocessor to help process the .idl file and MIDL provides a /cpp_cmd option to let user switch the preprocessor from cl.exe to say g++.exe. This is where I am stuck.

So in essence, I simply want MIDL to use g++.exe instead of cl.exe, but get an error
Wow! All I can say is good luck with that. I've never attempted anything like that.

Just off the top of my head, some things to consider...

1) Both MS VC and g++ can produce both x86 and x64. Are you sure there is no mixing and matching going on on that score? I produce both 32 bit and 64 bit versions of my ActiveX Grid control, and I'm pretty sure Midl comes in both 32 bit and 64 bit versions. I do all command line compiling, and use Visual Studio's Command Line Windows of the appropriate 'bittage' for either 32 bit or 64 bit compiles. The whole command line toolchain comes in both 32 bit and 64 bit versions, and that would be midl, rc, cvtres, and cl. I believe the same to be about true for g++;

2) It looks like you are attempting to create a 64 bit dll or 64 bit code. And this for Excel use somehow (I'm unfamiliar with *.xla files, unfortunately). Is your version of Office or Excel a 64 bit version? Wouldn't that be necessary? Its my understanding that 64 bit versions of Office or Excel are uncommon. Maybe I'm wrong there. Where I work we do 32 bit only.

Wish I could help more, but that's about all I can come up with.
Thanks for the tips.

1) Yes, there doesn't seem to be any mixing/matching.

2) Yes, I am trying everything with 64-bit (including Excel) and will try 32-bit later.

I was able to get li'l further. Issue seemed like g++ doesn't recognize .idl files. So I passed "-x c-header" flag to it. It is now able to successfully preprocess ABC.idl, which unfortunately brings in Win SDK specific .idl files -> g++ later blows up at __stdcall. I'll check if I can resolve this bit now.

C:\Program Files (x86)\Windows Kits\8.1\Include\um\unknwnbase.idl(179) : error MIDL2025 : syntax error : expecting a type specification near "("
C:\Program Files (x86)\Windows Kits\8.1\Include\um\unknwnbase.idl(179) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation

line 178: [call_as(LockServer)]
line 179: HRESULT __stdcall RemoteLockServer(
line 180: [in] BOOL fLock);
closed account (E0p9LyTq)
hazdazzler009 wrote:
Since Visual Studio is not free

Visual Studio 2015 Community is free:
https://www.visualstudio.com/products/free-developer-offers-vs

Compare editions - https://www.visualstudio.com/products/compare-visual-studio-2015-products-vs

If you decide to get VS 2015 Community I suggest you download the ISO and do a custom install. There are several features not installed when doing a typical install, such as the C/C++ compiler.
Topic archived. No new replies allowed.