Reputation: 13055
How can I use g++ compiler under the IDE of MS visual studio?
Upvotes: 3
Views: 7583
Reputation:
Running G++ from within Visual Studio may be the wrong approach.
A good alternative is to use CMake as your primary build tool. It can generate makefiles that will build your project with MinGW G++ (or Linux/Unix G++), or it can generate project/solution files for Visual Studio. Build folders are normally separate from the source folders, so it's easy to have multiple builds of the same source.
This means, in addition to portable building, that you get a lot of freedom to use the best tool for the job at any time. Need to do some coverage analysis and you may do a MinGW G++ build with GCOV support. Need to do some debugging, and you may prefer to work from a Visual Studio build.
CMake isn't exactly trivial to get started with, but it is IMO well worth that initial effort.
BTW - why do you want to run G++ from within Visual Studio? Your reason may affect the answer. For example, if you're concerned about distributing code developed using an express edition, don't worry. The Visual Studio Express Edition licenses grant the right to sell and otherwise distribute code that you develop using them anyway, even though they are free (in the beer sense).
Upvotes: 2