1
votes

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.

1
Why would you even bother to build them from within QtCreator? Furthermore this does not work, as QtCreator will try to use an existing Qt installation to compile a new one (as soon as the qmake step is executed. Running only make is identical to typing make in a terminal). Thats simply not supposed to be done, which is why you start getting strange and nonsensical errors... - Felix
@Felix, I wanted to try out some changes in the library and I actually like QtCreator as editor. As I did not set up a qt project in this case I also did not expect QtCreator to pull in system libraries from qt just by default. - Patrick Fromberg
Well, that is a valid reason. You can technically use QtCreator as editor only, without ever running a build step and do that from the console instead. However, I posted an answer how to get this setup working correctly. - Felix

1 Answers

1
votes

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:

  1. Run the configure script (and add the -developer-build option)
  2. Open QtCreator and go to "Tools > Options > Kits"
  3. Go to "Qt Versions" add press "Add" - select the qmake executable generated by the configure script. Then hit "Apply"
  4. Go to "Kits" and press "Add" - Make shure to select the correct compilers and debugger and select the previously create "Qt Version". Press "Ok"
  5. 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:

  1. Run the configure script (and add the -developer-build option)
  2. Run make qmake_all in the same terminal to let Qt prepare all makefiles, create headers etc.
  3. Open the top level .pro file in QtCreator. You can choose any kit.
  4. Go to Project > Your Kit > Build and disable the "qmake" step (the first of the default 2 steps)
  5. Change the "build directory" to be wherever you built Qt - either a shadow build or the source directory
  6. 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.