What is the "The build directory needs to be at the same level as the source directory" warning?

  • Hello.

    The source code of my Qt projects is under subversion. By default, Qt Creator defines "Build directory" at the same level as project folder". For example, if my project is placed in /users/eye/work/testproject, the Qt Creator will use a build folder /users/eye/work/testproject-build-desktop. This is not very good since it messes the source tree and "unversioned" files under source control. So i defined a build folder to /tmp/testproject. All works fine, but during build i receive "The build directory needs to be at the same level as the source directory". Why such restriction and why build still successful?

  • It might just be the case that having the build dir on different level is untested, or could cause problems with relative paths.

  • Paths relative to the source folder will cause problems anyway?
    Maybe i need to report a problem to Qt bugtracker on this issue?

  • I had the same problem. Try to solve creating a build directory, separate but at the same level of the project:

    /usr/home/QTDevel/Project dir/sources -> for sources under version control
    /usr/home/QTDevel/Project fir/build_dir -> for debug and release builds

    Although if you have folders of files in the same version-control directory is not a real problem. It is a thing that happens usually in a lot of other environments and this is solved with, i.e. in git, exist the file .gitignore

  • Yes, i know that it's a lot of ways to ignore intermediate files in source control, scripts etc. But it's a good practice to keep a source tree clean from intermediate files :). So i'm trying to figure out that is the real problem and why Qt wants intermediate folder to be at same level as source folder O_O.

  • Moderators

    Qt does not care where you build, it is qmake that sometimes has trouble
    In some places qmake messes up pathes when the directories are at a different level. IIRC that was mostly related to resource file handling.

    The build will fail if this happens without any proper indication to the root cause. That is why I added this warning.

    Qmake does not care where the project is located, just how "far away" from / it is. Using /tmp/eye/work/testproject should work fine.

    PS: There is a bug report open for this issue, can't find it right now though.

  • Thank you for this great advice, Tobias. Now all is clear.

Log in to reply

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