How to select building target in QT Creator? - qt

I am trying to set up and run an open source application(LibreCAD) and I am following their Build From Source guide. In section "Building LibreCAD 2.0 on Windows" and under "Building LibreCAD in Qt-Creator" they state this:
Take care about the Shadow build option in Debug and Release
configuration. Disable this option in both configurations and save the
project.
Select librecad as building target in Qt Creator (instead of tff2lff, which is another choice)
If everything is good up to this point, you can build and run LibreCAD
within Qt-Creator.
I could not figure out how or/and where to do the second task. Could anyone help me please?
In Qt - Building for Multiple Platforms they say I need to "1.Click the Build and Run Kit Selector icon" and then to "2.Choose Build > Build Project". But I don't see any Kit Selector icon on my QT compiler!
And in Configuring Projects they say it is right here:
But on mine, it looks like disabled:
Edit:
This is how my "Kit Selector" looks like:

and then to "Choose Build > Build Project"
I'm not sure where you see that, but it's not on either of those pages.
They're talking about this thingy:
The "Build and Run Kit Selector icon" is on the button above the "Run" button (it's probably named like this because running an executable via this button implies that the target is built first).
In your project, tff2lff might be where app is in the screenshot, and librecad might be where test is, for example.

Related

how build the qt project itself using qtcreator

Update:
Because this was partly to have a project to code-browse the whole of qt, here is a much better way to do this: Code Browser by Woboq for C & C++
This even lets you browse into the includes outside the project like the system includes or the standard library.
Old Post:
My question is about Qt project in git://code.qt.io/qt/qt5.git repository. I checked out version 5.12.
My assumption is that qtcreator knows the qmake file but nothing about the configure command. Hence
I used the configure command to prepare the build in a shadow build directory
In QTCreator I opened qt.pro located in the git workspace
QTCreator opens the build settings dialog and I import them from the shadow build directory
Finally I click build in QTCreator.
But the compile window stalls when asking me for input. Qmake asks me about the licence type I want to choose. I had answered that already in the configure phase and even if I would agree to answer the question again, there is no prompt function in qtcreator's compile output window. Where did I go wrong?
If I forget about QTCreator and call make in the shadow build directory, then everything is build fine and without any licensing questions. When I then import the shadow build directory into a QTCreator, then I can build in QTCreator. But then I clicked Run qmake out of curiosity and I was back to square one, i.e. compile window asks me for input again and stops there forever.
Apart from my specific question I found no general documentation about building the qt libraries using QTCreator. I only find descriptions about compiling projects that use the Qt library.
Qt is not really meant to be compiled from within an IDE. However, this does not mean it's impossible to do. There are two ways to archive this:
First approach: Add the developer build as custom kit:
Run the configure script (and add the -developer-build option)
Open QtCreator and go to "Tools > Options > Kits"
Go to "Qt Versions" add press "Add" - select the qmake executable generated by the configure script. Then hit "Apply"
Go to "Kits" and press "Add" - Make shure to select the correct compilers and debugger and select the previously create "Qt Version". Press "Ok"
Open the top level .pro file in QtCreator and choose the previously created Kit. QtCreator will now use the correct qmake executable
This is the "proper" way to go. You can now use the project as any normal project, including changes to pro-files. Also, QtCreator now correctly detects the build directory, so you won't have to change that, even when opening one of the modules.
Second approach: Use as a normal project without qmake:
Run the configure script (and add the -developer-build option)
Run make qmake_all in the same terminal to let Qt prepare all makefiles, create headers etc.
Open the top level .pro file in QtCreator. You can choose any kit.
Go to Project > Your Kit > Build and disable the "qmake" step (the first of the default 2 steps)
Change the "build directory" to be wherever you built Qt - either a shadow build or the source directory
Hit Build and QtCreator will invoke make only, archieving the same behaviour as running make from the console.
This is kind of a workaround and I would not recommend using it for a full Qt build, unless the first approach does not work for you for whatever reason.
This can also be useful if you only want to make changes to a single Qt module, without compiling the whole Qt framework, i.e. you can clone one of the submodules and use your "existing" qmake on it instead of compiling QtBase (in that case, you skip step 4)
Final notice: When I tried opening the whole Qt-Project, QtCreator crashed on my system because the project was to big to handle. I would recommend you to only open one of the modules within the super repostitory, i.e. "qtbase", "qtdeclarative", etc.

Qt5.5.1: How to create QT application that uses frameworks generated from qt-everywhere-opensource-src

I should have asked this question before asking this
I am creating a QT app (on MAC) that should use frameworks compiled from qt-everywhere-opensource-src-5.5.1.tgz and not the one that comes with qt-opensource-mac-x64-clang-5.5.0.dmg.
I use QT creator installed by that DMG file and qmake in it somehow links with the frameworks installed by this DMG. (see this for more details)
Whats the legit way of making this QT creator use other framework.
Qt Creator has the concept of build Kits. A kit includes (among other things) a compiler, debugger and Qt version. In the Qt Creator preferences, go to the Build & Run section. Under the Qt Versions tab, ensure that your Qt 5.5.1 built from source is listed there. Then go to the Kits tab and either create a new kit or modify an existing one. Ensure that kit is using your Qt 5.5.1 version.
Once you've got that sorted out, a project can have one or more kits associated with it. From the main window, go to the Projects panel. Near the top of the Build & Run tab of the projects page will be the section where you select the kit(s) for the project. Ensure your project is using the kit you created/modified which uses your Qt 5.5.1. That should be enough to get your project building with your version of Qt instead of the one that comes with Qt Creator. To be absolutely sure, perhaps delete any previous build before you switch kits or even better, create a new build configuration in a new build/output directory for it.

Running debug mode in Qt Creator

I am trying to compile some demo code (specifically, the pcl_visualizer demo that comes with the Point Cloud library). When running debug by clicking the green arrow with the magnifying class, I get the following errors:
This does not seem to be a "Debug" build.
Setting breakpoints by file name and line number may fail.
Section .debug_info: Not found.
Section .debug_abbrev: Not found.
Section .debug_line: Not found.
Section .debug_str: Not found.
Section .debug_loc: Not found.
Section .debug_range: Not found.
Section .gdb_index: Not found.
Section .note.gnu.build-id: Found.
Section .gnu.hash: Found.
Section .gnu_debuglink: Not found.
Furthermore, none of the breakpoints I have inserted are breaking the program, and they all have little hourglasses hovering over.
In Projects, the Debug mode is selected in Build Settings.
Why does my code not seem to be debugging correctly?
Some projects automatically build debug mode and allow to run it individually. You can then pick it in the bottom left Run selection menu.
Other projects require you to specifically do a debug build.
For example: Kdenlive requires you to run CMake again with the following parameter added:
-DCMAKE_BUILD_TYPE=Debug
You can re-run CMake in the Projects view.
For newer versions of QT:
Go to "Projects" in the top left of the screen, an icon with a wrench that turns green when you select it.
If not already "clicked", click on "Build" under the named Kit (I have "desktop" as my kit). This should be immediately below "Build & Run" on the left side.
Under Build Settings at the top center, should have "Edit build configuration" with a drop down next to it. If you can select "Debug" from the drop down then do it, otherwise click "Add" in the drop down next to it and select "Debug".
Drop down some and see "Key" on the left side of a table of "Key"s with "Value"s, look farther right and see "Advanced" with a square, check the square to get the advanced Key-Value pairs.
Look for "CMAKE_BUILD_TYPE" and click "Edit" in the far right, change the drop down for the value matched to the key CMAKE_BUILD_TYPE to "debug".
Now in the bottom left, change the build configuration to "debug" and build... should work!
You may have to Clean the project and possibly clear cmake configuration under the Build tab.
Another cause for the "does not appear to be a debug build" message is running gdb using the cdb engine. to check go to tools->options->build and run->kits and select the kit you are using. next go to the debugger line, choose edit, and make sure you have the right engine for your debugger.
On linux using the 'Qt Maintenance tool' to install the 'Qt Debug Information Files' solved this for me
I've got the same message because the build type was set to release. On Qt Creator 3.3.0 on the bottom left, on top of the play symbol i have a pc icon with the build type. click on that icon and select debug.
I needed to 'run qmake' too from the menu build.
For nasm users with QT5.9.1 and nasm 2.14 the problem will be gone by using:
nasm -felf64 -FDwarf -g
I know it's not c/c++ related but works very well in QT
To change the Build Configuration in QT Creator :(at time of writing : 4.13.3)
Just make sure you have selected this as Debug so that it would then run in debug mode.
I managed to solve this by unchecking "Warn when debugging Release builds" in the Debug settings General tab, as in the article:
http://www.kdab.com/qt-on-android-episode-2/

Qt - 'Shadow Building'?

I have a simple question - what is Shadow Building? I've seen it in Qt in Target Setup dialog, but don't know what it does or if I should use it.
It's also present in Projects tab, under General group.
Shadow building is a technique used to build different Qt builds of the same version for different platforms/compilers/etc. Your compiled build is in a different directory, separate from the original Qt source directory.
I've created a shadow build for my MSVS2010 compiler. If I wanted to, I could create a new build for MinGW in a different build directory.
See the definition here, and more information about configuring your build here.
Additional information for Mateen's answer.
By default, Qt Creator builds projects in a separate directory from the source directory, as shadow builds. This keeps the files generated for each build and run kit separate. If you only build and run with a single kit, you can deselect the Shadow build checkbox.
https://doc.qt.io/qtcreator/creator-build-settings.html#qmake-build-configuration

Qt Creator: is there something like VS solution in which you can add projects and set project dependencies and build order?

I have one of the latest versions of Qt Creator.
is there something like VS solution? In which you can add projects and set project dependencies and build order?
if I have multiple open projects, how do I set one of them as "default", so that Ctrl+B builds specifically that project?
I think the "solution" you are looking for is the project_name.pro.user file that gets created when you open a .pro file in QtCreator. It's an XML file that describes build steps, build environment, etc. for your project. When your project is open in QtCreator, go in the "Projects" tab (from the left), then in the "Dependencies" tab, where you can check all other (open) projects that this project depends on, and thus must be built first. You can repeat for each project, then QtCreator will figure a build order that satisfies all dependencies (unless there are cyclic dependencies).
Go in the "Projects" tab (on the left), then select the project you want to be "default" from the top bar, and go back in Edit mode. The project you selected will show in bold in the project sidebar, which means it's the one tied to the "Build project" shortcut.

Resources