Qt and DESTDIR being ignored? - qt

My app folder is "app"
It contains both .pro and source files
It has a "bin" folder.
the "DESTDIR = bin\" in my .pro file
however, when building from Qt-Creator, a sibling folder is being created, called "app-build-desktop" and the binaries are stored there under a new "bin" folder.
why is this happening? why is another sibling folder being created and hosts a new bin folder instead of just creating the binary file in my existing "bin" folder.

In the "Projects" area (on the left pane of Qt Creator) there is a "Shadow build" option in the Build Settings. You can uncheck this to disable it.
That being said, it is a useful feature, for example for keeping your actual source directory clean of temporary files that you have to ignore in source control.

Related

Qt renaming path of the project

sometimes when I rename the path to a qt project, it cannot be run even though I clean qmake and rebuild it!!! the path does not contain any space. and the project is completely correct and I know that the error is for path renaming , for example when I rename :
D:/abd/projects/LAND_2/Land_QT/...
to
D:/abd/projects/LAND_2/Land2_QT_SA/...
it cannot be build and says that some include file is missing(but the file is there!).
what is the problem?
I work with dynamic qt5.2 on windows 7.
Edit:
when I copy the project folder to a new directory( a path upper than current path) then the project can be build and run.
When you rename the path to the project, go to the project folder and delete the file with .pro.user extension. Open the project and Qt will ask you to configure the project. Choose the required kit, build and run the project.It should build successfully now
If you have changed path multiple times the .pro.user file is created multiple times delete all files with this extension and compile

How do I add an entire directory to a QT creator project

I have an existing QT Creator project. I want to add an entire directory to this project. I see that I can right click in the project file browser tree and "Add Existing Files..." However through this dialog box, I can only add individual files. How can I include an entire directory?
The simplest way is to directly edit your .pro file, add HEADERS += mydir/*.h and SOURCES += mydir/*.cpp and the contents of the whole directory will show up in QT Creator. Further reference: http://qt-project.org/doc/qt-5/qmake-project-files.html
Open a terminal, navigate to the folder where you want to have you project file, and then run the command
qmake -project
This will search the current directory and all subdirectories for files with extensions such as .c, .cpp, .h, etc. (the full list is found by typing man qmake).
But keep in mind that it will overwrite your current .pro file if you already have a project set up.
qmake provides a convenient files function for this very purpose. Adding the following line to your project file will add .cpp files inside the src/ directory:
SOURCES += $$files(src/*.cpp)
By default, this is non-recursive. Setting the second parameter to true recursively finds all files:
SOURCES += $$files(src/*.cpp, true)
The files function was introduced since Qt 5.10.
Nowadays you can just right click on project name and select Add existing directory

Qmake does not support build directories below the source directory

I have created an application that compiles and runs like a charm on OS-X. I would now like to start getting it to work on Windows. To start, I copied the project to a windows machine and just tried to compile, but got this error:
:: warning: Qmake does not support build directories below the source directory.
Any ideas?
Set the shadow build directory to some folder on the same level of your project directory:
folder/
project/
project-shadow-build-release/
project-shadow-build-debug/
You can do this in the "Projects" view, via the toolbar on the left. To me, this warning was just an annoyance, a project never failed to build because of it.
Don't copy your project.pro.user file when you are copying a project from one machine to another, or from one directory to another. When you open the project, Qt Creator will offer to create a new build directory in the proper place.
Andref gave the correct answer to resolve this warning, but you may want to understand why this requirement exists.
In fact, the build directory must be at the same folder level as the project (i.e. it can't be above or below). The reason why is that the linker is called from the build directory. Hence, any relative paths to library files will be different than what you entered in your project file.
It kinda sucks. I like to put all intermediate files in their own folder. But you simply can't with qmake.
.pro.user are generated files by Qt Creator. They are unrelated to qmake and should not be touched (and not put into a VCS for that matter)
Just remove the files with the pro.user extension , worked for me
I also got this, trying to compile a project created on linux.
Another way to solve it is to change the paths in the .pro.user file (in the directory of your project)
Right Click on a project: Set As Active Project
Click on the Projects button (The one with the spanner image)
Edit build configuration : Debug / Profile / Release / and change the default directories, OR just uncheck the Shadow build check box.
The Build directory path should now change to black, from red

How to create a subdirectory for a project QtCreator?

I would like to divide my Qt project into several directories because it is growing pretty large. However, when I click on browse in QtCreator, there is no 'Add directory' and no such thing in 'Add new'. Can this be done somehow?
One method you could use is to add a project include file for each sub directory.
Qt Creator displays these in the GUI in a nested fashion, and allows you to add files to them.
e.g.
in project.pro
include(folder1/include.pri)
in folder1/include.pri
HEADERS += MyClass.h
SOURCES += MyClass.cpp
etc
Answer : How to create a folder or a subdirectory for a project in QtCreator?
Prior to QT Creator 3.1.x, you can right-click on your project -> "add new..." and change the path to the folder you want.
The folder must exists, Qt will not create it for you.
Qt takes care of the path in your .pro file.
That's it !
Just had the same issue, and found out a relatively simple answer.
All you need to do to move file.cpp to newFolder is to rename the file (right click -> Rename) to newFolder\file.cpp.
Qt Creator will move it to the new folder and automatically update the .pro file.
Starting from version 1.2.90 Qt Creator shows subfolders which exist in project's folder as branches in project's tree if only Filter tree option is not set to Simplify tree.
It only seems to be impossible to create sub-directories in QT-CREATOR.
Try the following:
Create a number of sub-directories, with a file-explorer or by command line within the project-folder (for example net/, gui/, test/, data/ ...)!
Move exisiting files into these new folders. And change their paths within the *.proj file!
Create new also files from beginning within the new folders (By AddNew...)!
... QT-CREATOR displays only such folders which contain files that are written with their names into the *.pro or a *.pri file. At root level QT-CREATOR distinguishes between HEADERS, SOURCES, FORMS and OTHER FILES. Within these root folders you can find project-own subfolders, repeatedly. (Not covered in this text is splitting into sub-projects.)
When you create a new Class in your Qt-Project, you can choose the path in this wizard and hereby specify new folders like DAL, BO, UI, ...
You can create a sub-directory as long as you have a file you wish to create in it. Go to the parent directory, and "Add" a file to it. "Browse" for the location and create a new folder inside the browse window. Agreed, that is not quite intuitive.
Here's what I have done:
In the Project Folder (outside the IDE), create Directories that you'd like to put your code in and move your source files into those directories.
Say you put "foo.cpp" and "foo.h" in the directory "foo".
In your "*.pro" file, go to each line that references the source files you moved and add the directory name, followed by '/' in front of the source file name.
.pro before Step 2:
SOURCES += main.cpp \
foo.cpp
HEADERS += \
foo.h \
.pro after Step 2:
SOURCES += main.cpp \
foo/foo.cpp
HEADERS += \
foo/foo.h
Rebuild your project to test.
When my 'data' directory only had one sub-directory 'model' it just appeared as "data/model". After adding 'dao' as another sub-directory it displayed data with the traditional +/- manner to reveal model and dao.
you can add folders in your folders manager but they should contain a file, then go QT and right-click on your project then click on "add existing directory" and select your folder. if the folder is empty it's not going to show up.

Eclipse CDT static resources under build folder

I'm building a C++ project under Eclipse and my release folder should include a static sub-folder with some files inside it, those are required by executable during runtime. The problem is that this folder is automatically deleted before every build - entire release folder is completely wiped out and I'm losing all the files inside it.
Solution is simple - need to place rm.exe from mingw utilites on path and Eclipse will delete only specific build files instead of removing entire release folder.

Resources