Please nominate your Qt Champions for 2021!

Qmake and white spaces in TARGET, DESTDIR, etc...

  • Apparently Qmake (or more precisely g++ ) is allergic to spaces. I have sub-projects which compile to a lib directory, and the main project use these libraries. So I want these projects to know the path to the destination directory. On Windows I have been using the BASH wildcard (DOCUME~1) to be able to compile, but I need something better. My code will be used by lot of people at the office and I want to avoid the memo "NO SPACE IN PATH!!".

    ps: I use Qmake 2.01a and I tried (without success of course)

    • $$quotes()

    • $$escape_expand()

  • Spaces in qmake are (at least in my experience) handled differently per setting. I've had the most luck with good old trial and error. Oftentimes you have to multiple escape characters. Like for example:
    @\\ @
    @\\\ @

    I've also had luck with quoting "\\ " and other techniques. It has often proved useful to have a look at the generated Makefile and at the actual command produced at the command line. Check if it is what you would have typed in in that case, then add or remove backslashes or quotes as necessary. If that all doesn't work, I'm afraid you'll have to stick to the "No spaces" mantra.

Log in to reply