[SOLVED] MSVC 2012 cannot autodetect include paths



  • 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.


  • Lifetime Qt Champion

    Hi,

    Are you using Visual Studio directly or Qt Creator ?



  • [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).



  • 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.


  • Lifetime Qt Champion

    Are you sure you have all include path setup correctly in your pro file ?



  • [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 = subdirs

    SUBDIRS += StaticLibrary1
    StaticLibrary2
    MainApp

    CONFIG += 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.


  • Lifetime Qt Champion

    Do you have something like

    @INCLUDEPATH += $$PWD/../StaticLibrary1/include@

    in your MainApp pro file ?



  • [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).


  • Lifetime Qt Champion

    Then do you have

    @INCLUDEPATH += .@

    In your application pro file ?



  • No, but I added it and now the compiler seems happy. Why is that needed only with MSVC?

    Thanks for your help SGalst :)


  • Lifetime Qt Champion

    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 :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.