Important: Please read the Qt Code of Conduct -

Directory Separator in Makefiles

  • Hi there!

    I use qt 4.8.0 on windows xp, mingw 4.5.2, win32-g++

    My Problem is that in the Makefiles the directory separator for SOURCES is a "" whereas in the OBJECTS it is a "/". Even in the rest of the Makefile the separators are mixed up somehow.

    The Problem is that the compiler generates warnings like the following:

    code/log_event.h:59:16: warning: xxx
    code/log_event.h:58:18: warning: xxx
    code\log_event.cpp:15:1: warning: xxx

    With the "/" in the Warning it is hard to parse the path to the File. I need this for code analysis via Jenkins.

    If I change all "/" to "" in the OBJECTS then it works fine.

    Does anyone have a solution for this?

  • funny. the documentation says:

    This variable is generated from the SOURCES variable. The extension of each source file will have been replaced by .o (Unix) or .obj (Win32). The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified.

    In my Makefile qmake generates .o files.


  • oh, I just realized that it does not work if I exchange all "/" with "".

    I don't have a clue whats wrong.

  • Moderators

    Backslashes are tricky since C++ interprets them in a string as the start of an escape sequence (e.g. '\t' for the tab character). So you need to escape the backslashes by prepending another backslash. That is also true for most other environments like build systems.

    In qmake you should always use '/' as a directory separator, even on windows. That gets you round the escaping issue and -- as an added benefit -- will work on all supported platforms.

Log in to reply