When executing step qmake linux
Hello all.
I’ve just bought a new laptop, installed Linux Mint on it, as well as Qt.
On the HelloWorld exercise from the book «Application Development with Qt Creator» I hit the green arrow to compile and run the project, but I’m getting the following error message.
Many thanks if you can tell me how to resolve this.
Thanks!
Error while building/deploying project HelloWorldConsole (kit: Desktop Qt 5.7.1 GCC 64bit)
When executing step «qmake»
Kit may not have configured properly. Can u check in tools, options,build&run ? Under kits section do you see red flag ?
Nope, thanks.!
It reads «Auto-detected»
@KyleD Can you show the content of the «Compile Output» tab in QtCreator?
@KyleD It sounds like it can’t find qmake.. If on the command line, make sure to set QTDIR to your Qt path, and include /path/to/qt/bin in your PATH.
Then you can run qmake && make .. If that works then go back and try again with qt creator. If it still doesn’t work it’s almost guaranteed to be in your kit settings somewhere.
Thanks for the responses.
At first, I didn’t have g++ installed. I thought Qt would have done this for me. So, after installing g++, I now get this message in the «Application Output» tab:
And it just doesn’t do anything else. But that is ok, because when I try the QtGUI example, it does work! And that’s what I’m interested in.
I’m guessing Qt just doesn’t have permission to launch Terminal since I’m on Linux.
Источник
Qt Documentation
Contents
The behavior of qmake can be customized when it is run by specifying various options on the command line. These allow the build process to be fine-tuned, provide useful diagnostic information, and can be used to specify the target platform for your project.
Command Syntax
The syntax used to run qmake takes the following simple form:
Operating Modes
qmake supports two different modes of operation. In the default mode, qmake uses the information in a project file to generate a Makefile, but it is also possible to use qmake to generate project files. If you want to explicitly set the mode, you must specify it before all other options. The mode can be either of the following two values:
- -makefile
qmake output will be a Makefile. - -project
qmake output will be a project file.
Note: It is likely that the created file will need to be edited. For example, adding the QT variable to suit what modules are required for the project.
You can use the options to specify both general and mode-specific settings. Options that only apply to the Makefile mode are described in the Makefile Mode Options section, whereas options that influence the creation of project files are described in the Project Mode Options section.
Files
The files argument represents a list of one or more project files, separated by spaces.
General Options
A wide range of options can be specified on the command line to qmake in order to customize the build process, and to override default settings for your platform. The following basic options provide help on using qmake, specify where qmake writes the output file, and control the level of debugging information that will be written to the console:
- -help
qmake will go over these features and give some useful help. - -o file
qmake output will be directed to file . If this option is not specified, qmake will try to use a suitable file name for its output, depending on the mode it is running in.
If ‘-‘ is specified, output is directed to stdout. - -d
qmake will output debugging information. Adding -d more than once increases verbosity.
The template used for the project is usually specified by the TEMPLATE variable in the project file. You can override or modify this by using the following options:
- -t tmpl
qmake will override any set TEMPLATE variables with tmpl , but only after the .pro file has been processed. - -tp prefix
qmake will add prefix to the TEMPLATE variable.
The level of warning information can be fine-tuned to help you find problems in your project file:
- -Wall
qmake will report all known warnings. - -Wnone
No warning information will be generated by qmake. - -Wparser
qmake will only generate parser warnings. This will alert you to common pitfalls and potential problems in the parsing of your project files. - -Wlogic
qmake will warn of common pitfalls and potential problems in your project file. For example, qmake will report multiple occurrences of files in lists and missing files.
Makefile Mode Options
In Makefile mode, qmake will generate a Makefile that is used to build the project. Additionally, the following options may be used in this mode to influence the way the project file is generated:
- -after
qmake will process assignments given on the command line after the specified files. - -nocache
qmake will ignore the .qmake.cache file. - -nodepend
qmake will not generate any dependency information. - -cache file
qmake will use file as the cache file, ignoring any other .qmake.cache files found. - -spec spec
qmake will use spec as a path to platform and compiler information, and ignore the value of QMAKESPEC.
You may also pass qmake assignments on the command line. They are processed before all of the files specified. For example, the following command generates a Makefile from test.pro:
However, some of the specified options can be omitted as they are default values:
If you are certain you want your variables processed after the files specified, then you may pass the -after option. When this is specified, all assignments on the command line after the -after option will be postponed until after the specified files are parsed.
Project Mode Options
In project mode, qmake will generate a project file. Additionally, you may supply the following options in this mode:
- -r
qmake will look through supplied directories recursively. - -nopwd
qmake will not look in your current working directory for source code. It will only use the specified files .
In this mode, the files argument can be a list of files or directories. If a directory is specified, it will be included in the DEPENDPATH variable, and relevant code from there will be included in the generated project file. If a file is given, it will be appended to the correct variable, depending on its extension. For example, UI files are added to FORMS, and C++ files are added to SOURCES.
You may also pass assignments on the command line in this mode. When doing so, these assignments will be placed last in the generated project file.
В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Источник
Qt Documentation
Contents
Adding New Configuration Features
qmake lets you create your own features that can be included in project files by adding their names to the list of values specified by the CONFIG variable. Features are collections of custom functions and definitions in .prf files that can reside in one of many standard directories. The locations of these directories are defined in a number of places, and qmake checks each of them in the following order when it looks for .prf files:
- In a directory listed in the QMAKEFEATURES environment variable that contains a list of directories delimited by the platform’s path list separator (colon for Unix, semicolon for Windows).
- In a directory listed in the QMAKEFEATURES property variable that contains a list of directories delimited by the platform’s path list separator.
- In a features directory residing within a mkspecs directory. mkspecs directories can be located beneath any of the directories listed in the QMAKEPATH environment variable that contains a list of directories delimited by the platform’s path list separator. For example: $QMAKEPATH/mkspecs/ .
- In a features directory residing beneath the directory provided by the QMAKESPEC environment variable. For example: $QMAKESPEC/ .
- In a features directory residing in the data_install/mkspecs directory. For example: data_install/mkspecs/ .
- In a features directory that exists as a sibling of the directory specified by the QMAKESPEC environment variable. For example: $QMAKESPEC/../ .
The following features directories are searched for features files:
- features/unix , features/win32 , or features/macx , depending on the platform in use
- features/
For example, consider the following assignment in a project file:
With this addition to the CONFIG variable, qmake will search the locations listed above for the myfeatures.prf file after it has finished parsing your project file. On Unix systems, it will look for the following file:
- $QMAKEFEATURES/myfeatures.prf (for each directory listed in the QMAKEFEATURES environment variable)
- $$QMAKEFEATURES/myfeatures.prf (for each directory listed in the QMAKEFEATURES property variable)
- myfeatures.prf (in the project’s root directory). The project root is determined by the top-level .pro file. However, if you place the .qmake.cache file in a sub-directory or the directory of a sub-project, then the project root becomes the sub-directory itself.
- $QMAKEPATH/mkspecs/features/unix/myfeatures.prf and $QMAKEPATH/mkspecs/features/myfeatures.prf (for each directory listed in the QMAKEPATH environment variable)
- $QMAKESPEC/features/unix/myfeatures.prf and $QMAKESPEC/features/myfeatures.prf
- data_install/mkspecs/features/unix/myfeatures.prf and data_install/mkspecs/features/myfeatures.prf
- $QMAKESPEC/../features/unix/myfeatures.prf and $QMAKESPEC/../features/myfeatures.prf
Note: The .prf files must have names in lower case.
Installing Files
It is common on Unix to also use the build tool to install applications and libraries; for example, by invoking make install . For this reason, qmake has the concept of an install set , an object which contains instructions about the way a part of a project is to be installed. For example, a collection of documentation files can be described in the following way:
The path member informs qmake that the files should be installed in /usr/local/program/doc (the path member), and the files member specifies the files that should be copied to the installation directory. In this case, everything in the docs directory will be copied to /usr/local/program/doc .
Once an install set has been fully described, you can append it to the install list with a line like this:
qmake will ensure that the specified files are copied to the installation directory. If you require more control over this process, you can also provide a definition for the extra member of the object. For example, the following line tells qmake to execute a series of commands for this install set:
The unix scope ensures that these particular commands are only executed on Unix platforms. Appropriate commands for other platforms can be defined using other scope rules.
Commands specified in the extra member are executed before the instructions in the other members of the object are performed.
If you append a built-in install set to the INSTALLS variable and do not specify files or extra members, qmake will decide what needs to be copied for you. Currently, the target and dlltarget install sets are supported. For example:
In the above lines, qmake knows what needs to be copied, and will handle the installation process automatically.
Adding Custom Targets
qmake tries to do everything expected of a cross-platform build tool. This is often less than ideal when you really need to run special platform-dependent commands. This can be achieved with specific instructions to the different qmake backends.
Customization of the Makefile output is performed through an object-style API as found in other places in qmake. Objects are defined automatically by specifying their members. For example:
The definitions above define a qmake target called mytarget , containing a Makefile target called .buildfile which in turn is generated with the touch command. Finally, the .depends member specifies that mytarget depends on mytarget2 , another target that is defined afterwards. mytarget2 is a dummy target. It is only defined to echo some text to the console.
The final step is to use the QMAKE_EXTRA_TARGETS variable to instruct qmake that this object is a target to be built:
This is all you need to do to actually build custom targets. Of course, you may want to tie one of these targets to the qmake build target. To do this, you simply need to include your Makefile target in the list of PRE_TARGETDEPS.
Custom target specifications support the following members:
Member | Description |
---|---|
commands | The commands for generating the custom build target. |
CONFIG | Specific configuration options for the custom build target. Can be set to recursive to indicate that rules should be created in the Makefile to call the relevant target inside the sub-target specific Makefile. This member defaults to creating an entry for each of the sub-targets. |
depends | The existing build targets that the custom build target depends on. |
recurse | Specifies which sub-targets should be used when creating the rules in the Makefile to call in the sub-target specific Makefile. This member is used only when recursive is set in CONFIG . Typical values are «Debug» and «Release». |
recurse_target | Specifies the target that should be built via the sub-target Makefile for the rule in the Makefile. This member adds something like $(MAKE) -f Makefile.[subtarget] [recurse_target] . This member is used only when recursive is set in CONFIG . |
target | The name of the custom build target. |
Adding Compilers
It is possible to customize qmake to support new compilers and preprocessors:
With the above definitions, you can use a drop-in replacement for moc if one is available. The command is executed on all arguments given to the NEW_HEADERS variable (from the input member), and the result is written to the file defined by the output member. This file is added to the other source files in the project. Additionally, qmake will execute depend_command to generate dependency information, and place this information in the project as well.
Custom compiler specifications support the following members:
Member | Description |
---|---|
commands | The commands used for for generating the output from the input. |
CONFIG | Specific configuration options for the custom compiler. See the CONFIG table for details. |
depend_command | Specifies a command used to generate the list of dependencies for the output. |
dependency_type | Specifies the type of file the output is. If it is a known type (such as TYPE_C, TYPE_UI, TYPE_QRC), it is handled as one of those type of files. |
depends | Specifies the dependencies of the output file. |
input | The variable that specifies the files that should be processed with the custom compiler. |
name | A description of what the custom compiler is doing. This is only used in some backends. |
output | The filename that is created from the custom compiler. |
output_function | Specifies a custom qmake function that is used to specify the filename to be created. |
variables | Indicates that the variables specified here are replaced with $(QMAKE_COMP_VARNAME) when referred to in the pro file as $(VARNAME). |
variable_out | The variable that the files created from the output should be added to. |
The CONFIG member supports the following options:
Option | Description |
---|---|
combine | Indicates that all of the input files are combined into a single output file. |
target_predeps | Indicates that the output should be added to the list of PRE_TARGETDEPS. |
explicit_dependencies | The dependencies for the output only get generated from the depends member and from nowhere else. |
dep_existing_only | Every dependency that is a result of .depend_command is checked for existence. Non-existing dependencies are ignored. This value was introduced in Qt 5.13.2. |
dep_lines | The output from the .depend_command is interpreted to be one file per line. The default is to split on whitespace and is maintained only for backwards compatibility reasons. |
no_link | Indicates that the output should not be added to the list of objects to be linked in. |
Library Dependencies
Often when linking against a library, qmake relies on the underlying platform to know what other libraries this library links against, and lets the platform pull them in. In many cases, however, this is not sufficient. For example, when statically linking a library, no other libraries are linked to, and therefore no dependencies to those libraries are created. However, an application that later links against this library will need to know where to find the symbols that the static library will require. qmake attempts to keep track of the dependencies of a library, where appropriate, if you explicitly enable tracking.
The first step is to enable dependency tracking in the library itself. To do this you must tell qmake to save information about the library:
This is only relevant to the lib template, and will be ignored for all others. When this option is enabled, qmake will create a file ending in .prl which will save some meta-information about the library. This metafile is just like an ordinary project file, but only contains internal variable declarations. When installing this library, by specifying it as a target in an INSTALLS declaration, qmake will automatically copy the .prl file to the installation path.
The second step in this process is to enable reading of this meta information in the applications that use the static library:
When this is enabled, qmake will process all libraries linked to by the application and find their meta-information. qmake will use this to determine the relevant linking information, specifically adding values to the application project file’s list of DEFINES as well as LIBS. Once qmake has processed this file, it will then look through the newly introduced libraries in the LIBS variable, and find their dependent .prl files, continuing until all libraries have been resolved. At this point, the Makefile is created as usual, and the libraries are linked explicitly against the application.
The .prl files should be created by qmake only, and should not be transferred between operating systems, as they may contain platform-dependent information.
В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Источник