PDA

View Full Version : Is it possible to use MinGW compiler in Visual Studio



Dauntless
23rd March 2007, 23:54
I have Visual Studio 2005, but I want to compile code that uses libraries available only in Unix. The native VS compiler can’t compile it and only MinGW can translate the code so it works on Windows. Is it possible to change the compiler in Visual Studio so it uses MinGW?

wysota
24th March 2007, 00:00
Yes, it's possible. Either reconfigure Visual Studio to do a custom build or simply change the QMAKESPEC to win32-g++ (or something like that) and use qmake to generate a VS project (pass -tp vc option to qmake).

Dauntless
24th March 2007, 00:50
Thank you for your help, but it doesn't work yet.

I get this warnings/errors when I use use qmake to generate a VS project (pass -tp vc option to qmake) with QMAKESPEC set to win32-g++:
WARNING: Unable to generate output for: C:/SVN/[...]/Makefile.Debug [TE
MPLATE vcapp]
WARNING: Unable to generate output for: C:/SVN/[...]/Makefile.Release [
TEMPLATE vcapp]

and it doesn't make the .vcproj file :(

N.B. It works well if I let QMAKESPEC set to win32-msvc2005 but it's not what I am looking for.

wysota
24th March 2007, 09:18
So maybe you can't have a vs project generated by QMake. In that case you have to use QMake directly (without generating the VS project) - create a custom build that simply calls qmake and mingw-make.

Dauntless
24th March 2007, 10:59
I tried doing that but I lose the debugging information for my program. I get a "binary was not build with debug information" error, and without the powerful debugging tool that VS has, I think I will go back to QDevelop where at least I have one.

Here (http://msdn2.microsoft.com/en-us/library/aa730877(vs.80).aspx)'s an article about custom builds that some might find interesting if they use VS.

N.B. I did make the debug (not the release) version of my program with mingw32-g++.

wysota
24th March 2007, 11:03
For debugging you can compile with MSVC. I don't think Visual Studio can debug MinGW compiled binaries.

Dauntless
24th March 2007, 11:11
MSVC can't compile parts of my code because I use C POSIX libraries. I know, I have to translate the code myself so it will use win32 api but it is a lot of work and I was thinking if it was possible to change just the compiler so I would use minGW, which does that job for me. Well, anyhow, thanks for your time wysota, I guess I'll stick with QDevelop for now...

wysota
24th March 2007, 13:53
You mean that MSVC has trouble compiling those posix libraries? MSVC has come a long way - it shouldn't have trouble with C code...