Constantin
Constantin

Reputation: 8961

Integrate MinGW with Visual Studio 2010 (Makefile Project)

I'm trying to get MinGW (Version 4.7.2) working with Visual Studio 2010 to use some of the new C++11 features (sadly I'm still on WindowsXP and can't use Visual Studio 2012). To get started, I created a project with: File -> New Project -> Visual C++ -> General -> Makefile-Project

General:
Build Command Line: mingw32-make.exe
Rebuild All Command Line: mingw32-make.exe rebuild all
Clean Command Line: mingw32-make.exe clean all

IntelliSense:
Include Search Path: C:\MinGW\lib\gcc\mingw32\4.7.2\include\c++;C:\MinGW\include;
Assembly Search Path: C:\MinGW\lib\gcc\mingw32\4.7.2;C:\MinGW\lib;
Additional Arguments: -std=c++11

And I created an makefile with the content:

all:
    g++ -std=c++11 -pthread -o Makefile_Test.exe main.cpp

It compiles just fine, but almost everything is wavy red underlined in Visual Studios editor. i.e.

std::vector<std::thread> threads;

std::vector -> 'Error: namespace std has no member vector'

std::thread -> 'Error: namespace std has no member thread'

even std::cout << "";

std::cout -> 'Error: namespace std has no member cout'

But I included the correspondending headers of course: and Visual Studio can even find them (place the cursor at #include -> Ctrl+Shift+G opens the header). My MinGw folder looks like the following:

+ MinGW
|- bin
|- doc
|- include
|+ lib
 |- gettext
 |+ gcc
  |+ mingw32
   |+ 4.7.2
    |- debug
    |+ include
     |- c++
     |...
    |- include-fixed
    |- install-tools
|- libexec
|- mingw32
|- msys
|- share
|- var

I also tried to delete the sdf file a few times and let Visual Studio rebuild it from scratch - but all these errors appeared again.

Any ideas what I'm doing wrong here?

Upvotes: 4

Views: 9286

Answers (2)

cargo
cargo

Reputation: 126

Using the Makefile project template like OP described. I have been able to get VC 2013 & 2015 Community edition's intellisense working, by adding the proper include dirs to the projects properties.

  1. Open the Project menu
  2. Select {Project Name} Properties
  3. Open the Configuration Properties
  4. select VC++ Directories in the tree menu
  5. Add Directories to the Includes Directories section

You do have to add the directories that contain the items you want read into intellisense. Say I am working on a gtkmm project, I'd also include the glibmm dir so the Glib::ustrings didn't get squiggles. Even if glibmm.h is not directly included in my source files.

Upvotes: 1

Andy Prowl
Andy Prowl

Reputation: 126432

I'm afraid you will have to give up your attempts to make those red squiggles disappear unless you disable them completely (so that, for instance, not even calls to non-existing functions will be marked).

The reason is that Visual Studio's Intellisense uses a separate front-end to EDG's C++ compiler to parse your program and possibly put a red squiggle under invalid statements or expressions, and the version used by Intellisense in VS2010 is (apparently) not fully compliant with C++11.

Therefore, switching to GCC 4.7.2 as the compiler will help building your C++11 programs, but won't affect the behavior of Intellisense.

If you want to disable the red squiggles completely, you can do it by selecting Tools -> Options -> Text Editor -> C/C++ -> Advanced, and setting "Disable Squiggles" to "True".

Upvotes: 9

Related Questions