How to install the GNU g ++ compiler in Visual Studio 2008

How to install the Visual Studio 2008 compiler in GNU GCC. Can I also use it for projects? I did not find a definitive answer.

Thanks.

+4
source share
5 answers

You cannot use the compiler directly.

You can, however, invoke the makefile instead of using the built-in build system.

Configuration Example:


  • Install MinGW (I think this step has already been taken), including mingw32-make
  • Create a make file for mingw32-make called MinGWMakefile with three goals: clean , build and rebuild . It can be very tiring if you have never done it before.
  • Create a new configuration for your project
  • Go to configuration properties -> general -> configuration type and select "makefile"
  • Go to configuration properties -> NMake and use these command lines:
      Build Command Line: mingw32-make -f MinGWMakefile build
     ReBuild Command Line: mingw32-make -f MinGWMakefile rebuild
     Clean Command Line: mingw32-make -f MinGWMakefile clean 

Enable the "go to line" function in compiler messages:


You need to convert gcc output from this:

 filename:line:message 

For this:

 filename(line):message 

I used a custom C ++ program, but any regex tool will do the trick.

+5
source

For best results, use GNU make, the Visual Studio Makefile project, and a tool you write yourself. Your makefile is a skeleton that compiles files (use a variable for a list of files), and your tool parses .sln and .vcproj files to create this list of files. The result file is included in the make file. You just need some grease for the glue and elbow - you will spend a day cursing by making an unwillingness to do what you want, then you will get his job. After starting this approach, not too much maintenance is required.

You can easily save your tool and makefile by simply throwing all the files in all projects into a mix and linking the result, using file templates to decide what happens with each file and putting all the compiler options in the make file. Or you can become smarter by pulling out #defines and including paths from the project and possibly adding a Win32 project configuration that the makefile generator uses to properly process custom build steps, excluded files, compiler options, etc.

An easy approach should satisfy the majority, since it allows someone to add new files to the project in the same way as they usually do without worrying about the make file, while at the same time making it difficult for people to accidentally change settings that they don’t want to change.

I previously described this approach (with a little more detailed information):

Good Methods for Using Makefile in VisualStudio?

(Once you have configured it, it works well, and in many ways it is more convenient than the usual VS approach, even if you do not take into account the fact that you can now use other compilers.)

+2
source

You can create your own makefile project to solve this problem.

Visual Studio's main script is an IDE for MS developer tools. The more common ways to compile using GNU tools on Windows are MinGW or Cygwin.

+1
source

Use an external build system. (Makefile project).

0
source

As far as I know, there is no way to do this. cl is more or less integrated with Visual Studio.

I think if you were really desperate, you could try to create a pre-build step that calls gcc, and then does something to stop the build of Visual Studio.

-2
source

All Articles