[SOLVED] MSVC 2012 cannot autodetect include paths
-
wrote on 6 Dec 2013, 08:37 last edited by
Hi,
I mostly use clang (occasionally also gcc) both on OS X and Linux, and also tried mingw on Windows. I wanted to try msvc on Windows because I find mingw slow, but it seems that with msvc I must be more explicit with my includes. For example, both with clang and gcc this is fine:
@
#include "myheader.h"
@With msvc I have to change it to something like this:
@
#include "../myheader.h"
@Is this a known peculiarity? I tried this on Windows 7 64bit, Qt 5.1.1, MSVC2012.
-
Hi,
Are you using Visual Studio directly or Qt Creator ?
-
wrote on 6 Dec 2013, 12:17 last edited by
[quote author="SGaist" date="1386331739"]Hi,
Are you using Visual Studio directly or Qt Creator ?[/quote]
Hi,
I'm using Qt Creator 2.8.1 (based on Qt 5.1.1, MSVC 2010, 32bit).
-
wrote on 6 Dec 2013, 12:36 last edited by
I also forgot to mention that while I'm typing the include, Qt Creator correctly finds the header and autocompletes it. The problem appears during compilation with a "file not found" error.
-
Are you sure you have all include path setup correctly in your pro file ?
-
wrote on 8 Dec 2013, 09:45 last edited by
[quote author="SGaist" date="1386459844"]Are you sure you have all include path setup correctly in your pro file ?[/quote]
I guess paths are fine, otherwise the project wouldn't compile properly with the other compilers. FWIW, it's a subdirs projects, with no .pri files (yet). My main .pro file looks like this:
@
TEMPLATE = subdirsSUBDIRS += StaticLibrary1
StaticLibrary2
MainAppCONFIG += ordered
@and in the MainApp project some files are organized into folders. Before removing it, mingw could also find all includes and compile the project just fine with this setup.
-
Do you have something like
@INCLUDEPATH += $$PWD/../StaticLibrary1/include@
in your MainApp pro file ?
-
wrote on 9 Dec 2013, 08:01 last edited by
[quote author="SGaist" date="1386536019"]Do you have something like
@INCLUDEPATH += $$PWD/../StaticLibrary1/include@
in your MainApp pro file ?[/quote]
Yes, MainApp.pro contains both the INCLUDEPATH and the DEPENDPATH for both libraries.
Actually, the headers that can't be found during compilation are all from MainApp -- the libraries do not have any folder hierarchy (each library's files are placed in a single folder).
-
Then do you have
@INCLUDEPATH += .@
In your application pro file ?
-
wrote on 9 Dec 2013, 08:55 last edited by
No, but I added it and now the compiler seems happy. Why is that needed only with MSVC?
Thanks for your help SGalst :)
-
That's a good question… Can you compare the Makefiles generated for both compilers without the "INCLUDEPATH += ." ?
Check whether the MinGW version has an additional include path corresponding to your application folder
You're welcome :)
7/11