Qt does not create output files in debug/release folders in Linux
I assume you're using qmake to do the actual building. You can edit the project files to put the output in different directories like this:
# only for unix:
unix {
# in debug mode...
CONFIG(debug, debug|release) {
DESTDIR = debug
}
else {
DESTDIR = release
}
}
Obviously in order for this to work you need to be building both debug and release executables. More information on this topic can be found here
Cheers
How to specify different Debug/Release output directories in QMake .pro file
The short answer is: you don't.
You should run qmake
followed by make
in whatever build directory you want to build in. So, run it once in a debug
directory, once in a release
directory.
That's how anyone building your project would expect it to work, and that's how Qt itself is set up to build, that's also how Qt Creator expects your .pro
file to behave: it simply starts qmake
and then make
in the build folder for your target's chosen configuration.
If you wish to create these folders and perform the two (or more) builds in them, you'll need a top-level makefile, possibly created from a top-level project file via qmake.
It's not uncommon to have more than two build configurations, so you're unnecessarily committing yourself to only differentiating between a build and a release; you might have builds with different optimization levels, etc. The debug/release dichotomy is best left to rest in peace.
Qt 5: Debug\release and Release\debug directories
If you are only using a single compiler, I would go into the Projects tab > Build > General > Shadow Build, and uncheck Shadow Build.
This will simplify the configuration and folder structure, and may fix the bug for you.
Maybe go in and do a build clean for good measure.
Hope that helps.
debug_and_release option didn't work for linux
Maybe the problem is that in your .pro file you should have set different target directories or different target file names. I do not know why but it looks like on Windows the target file names generated into your Makefiles are different and on Linux they are not different. You can try to change either your target directory or your target file name for debug build.
Try either
CONFIG(release, debug|release) {
TARGET = plugin
} else {
TARGET = plugind
}
or
CONFIG(release, debug|release) {
DESTDIR = release
OBJECTS_DIR = release/.obj
MOC_DIR = release/.moc
RCC_DIR = release/.rcc
UI_DIR = release/.ui
} else {
DESTDIR = debug
OBJECTS_DIR = debug/.obj
MOC_DIR = debug/.moc
RCC_DIR = debug/.rcc
UI_DIR = debug/.ui
}
How to change Debug/Release output dir using qmake .pro file. Cross-plataform
I think the reason it works on Windows and not on Linux is because you capitalized "Debug" and "Release". The examples I have found all have them as lower case (see second example in this section on the qmake document page.)
The other thing I question is the use of DESTDIRS. DESTDIRS tells qmake where you want to put the TARGET. If you want to directly control where only the object files are put, you should use OBJECT_DIRS.
Personally, I use qmake's INSTALLS keyword to do copy extra files where they need to go. It does mean executing both a make
and a make install
, but it does produce a more platform dependent code.
If I assume you want the TARGET and the objects in 'debug' or 'release', I would do it like this:
# Habilita a opcao de copia de diretorios
debug {
DESTDIR = debug
OBJ_DIR = debug
}
release
{
DESTDIR = release
OBJ_DIR = release
}
# copia a pasta configuracao para o diretorio de saida
config_files.path = $$DESTDIR
config_files.files = default_layout.kl
INSTALLS += config_files
If you are running QtCreator, you can add the make install
step to the building settings by selecting the "Projects" icon in the left hand tool bar. Next, select "Add Build Step", "Make", and set the "Make arguments" to install
. You will have to do this for each build configuration.
Is there anyway to stop MVSC from creating release and debug folders when using form QtCreator?
You can set CONFIG -= debug_and_release
in your .pro file and it will stop doing so.
Unable to customise the build directory for Qt Creator/qmake
The build directory is "specified" by starting qmake
or cmake
in the build directory. There's no point to setting it in the .pro
file itself.
Qt Creator stores the build directories for a project in the .user
file. Any changes made to this file outside of Qt Creator, while the project is open in the Creator, will be lost. Creator loads the file when opening the project, or creates a new one if it doesn't exist.
When the Creator starts the build by invoking qmake
or cmake
, it starts that process in the build directory. That's also how you should be building the project manually from the command line.
Finally, it makes very little sense to override the destinations of the intermediate build results. They are somewhere within the build directory, and that's all that matters. You're not using these files directly for anything anyway.
The customary way to build a qmake project:
mkdir project-build
cd project-build
qmake ~/project-src
make -j
The build folder should not be within the source tree!
I've recently started keeping them in $TEMP
/ %TEMP%
: manually purging the stale builds of all sort of test projects got old after a while :)
Related Topics
Disable CPU Caches (L1/L2) on Armv8-A Linux
Find' (Command) Finds Nothing with -Wholename
Need Some Advise to Begin Programming on Arm (With Linux) Platform
Where Is G_Multi Configured in Beaglebone Black
Sort a File Based on a Column in Another File
How to Selectively Create Symbolic Links to Specific Files in Another Directory in Linux
Reading Memory Pointed by Register with Gdb
How to Remove File with Special Characters
Elf File Tls and Load Program Sections
Inotify Fd - Why Is The Limit Per User Id and Not Per Process
How to I Detect Whether a Tty Belonging to a Gsm/3G-Modem Is a Data or Control Port
Git Error: Cannot Handle Https
Count Number of Column in a Pipe Delimited File