PDA

View Full Version : difference between command line compile and qtcreator compile.



skypuppy
30th December 2015, 09:38
I tried a VERY simple "hello, world" program today, to show up in a qt-derived window on the screen.
Doing it via command line was easy. One single .cpp program, with QApplication and QLabel used. (Source came from the Beaglebone Black book.) About 10 lines. From the command line, qmake - project, then make, and voila, an executable program.

So then I fired up qtcreator, opened that project: "training," and hit "build and run." It failed! There were several tweaks that had to be performed on the project in order for it to compile and run.

I though that very odd. Is this normal behavior, such difference between compiling from the command line versus in qtcreator?

Thanks,
Skypuppy

anda_skoa
30th December 2015, 10:47
No.
If you import the existing build then QtCreator usually just runs the program (since it is already built).

Cheers,
_

skypuppy
30th December 2015, 10:49
But that did not happen, Anda, as my original post describes.

anda_skoa
30th December 2015, 10:55
Maybe you didn't import the build but configured a new one, with a different Qt version?

E.g. if you create a project file with a Qt4 qmake and then configure a Qt5 build in QtCreator, a widget based application would require .pro modification for adding the widget module in a Qt5 specific section.

Cheers,
_

skypuppy
30th December 2015, 13:57
I have QT 5 set in my bash environment.

ChrisW67
30th December 2015, 20:38
But that did not happen, Anda, as my original post describes.
Your orignal post just says, "It failed!" and that you got it to go with, "several tweaks," that are also not described. We do not know where it failed (compile, link, or run), the mode of failure, or anything much about your environment except that it is likely a Linux box.

Qt Creator simply executes qmake, make, and then your program on your behalf. This flow is exactly the same as if you did it at the command line. Creator uses Kits to identify which copy of qmake is used, and thus which version of Qt and toolchain is used: there may be several on the same machine. The environment in which Creator runs qmake is controlled from your project's Build settings. The environment in which your program is run is set in your project's Run settings. All of these things may be different from the default version obtained from a basic command shell accounting for the unspecified problems.

skypuppy
30th December 2015, 22:50
Thank you, Chris. I did not know that!
So I go to tools->options-> kits to set those properly?
Once there, I get a bit lost.

ChrisW67
31st December 2015, 08:47
Essentially you define a Kit by telling Creator which Qt Library to use (defined on the Qt Versions tab by selecting the qmake from the library bundle) and which compiler (Compilers tab) and some other bits and pieces. The compiler selected must be the same (actually binary compatible, essentially the same thing) as the one used to build the Qt library selected. These Kits are then available to select in your project's Project panel, which is also where you define the compile-time and run-time environments.

skypuppy
31st December 2015, 12:04
How in the heck does one know which kit was used to build something? You've lost me completely here.

anda_skoa
31st December 2015, 13:20
You can see that in the Project settings (Project button on the left hand side in QtCreator).

A project can actually be configured for multiple kits and the active target chosen in the switcher above the "run" button.

Cheers,
_

skypuppy
31st December 2015, 13:58
The modules that come with Qt don't have associated project files that I can find. Am I missing something here?
I only have (one) project file and that is for the simple test that I put in.

ChrisW67
31st December 2015, 19:41
Assuming you used the Qt Online binary installer then you select Qt libraries (in the installer GUI) to install based on the bit-ness and compiler involved. There a quite a few combinations.
http://doc.qt.io/QtSupportedPlatforms/index.html

You can also download the library bundles individually, each labelled with the environment they are for. In Windows there are many different options. All Linux builds are with GCC and OS X uses LLVM/Clang (i think)
http://www.qt.io/download-open-source/#section-3

If you build the Qt libraries from source then you know what toolchains you used.

skypuppy
31st December 2015, 19:47
Debian Jessie both on desktop and RPi2.
Tried compiling from source on the RPi2 already and after 2 1/2 weeks of effort things were still missing. Debian repository actually has the solution with the most parts (but still not complete due to graphics engine not finished.)

Debian Jessie for the desktop is almost complete in their repositories EXCEPT for the qmake for cross compile version for armv7hf -- that is what I'm trying to find now. Can't find source code to compile either. Which is why I asked in here.

Debian Jessie is Linux version.

d_stranz
31st December 2015, 20:00
The modules that come with Qt don't have associated project files that I can find.

What do you mean by "modules"? The qtbase, widgets, and other directories in a Qt binary distribution? They may not, because they are binary distributions. If you've tried to configure a build from source, then the configuration script will possibly create them.

The "examples" directories do have .pro files, and when you open one in QtCreator you must configure the project to use whichever kits you want to use for compiling and building. I have kits installed for android, mingw, and both 32-bit and 64-bit versions of MSVC 2013. All of those a listed as possibilities when I open a project and go to the QtCreator Projects page and click on the Configure Project tab.

skypuppy
1st January 2016, 03:03
Thank you, d_stranz. I did not find them before so I will look again.