Generic c++ project in Qt creator - No rule to make target - c++

I am trying to import a generic project into Qt creator by following this tutorial.
The project has its Makefile which builds multiple separate executables.
Running make all in the root directory of the project builds everything correctly.
The project has been imported into Qt creator and the sources show no errors regarding includes. When I press build, i get the error No rule to make targetall'. Stop.` As if the Makefile is non existent.
Where is Qt creator looking for the Makefile?

In my case the problem was with the custom build directory in the Build Settings.
Qt creator was searching for the Makefile in the build directory.
When using Qt creatror for Qt projects, I've usually set the build directory to something custom but this isn't sensible here :)

Related

Qt: .pro file missing?

I tried to create a C++ project with Qt I stumbled across different kinds of guides which all refer to a special '.pro' file inside the project where I have to adjust a setting so the SQL part takes effect.
My problem: whenever I create a new project - doesn't matter whether its with qbs, qmake, or cmake - the project structure/ folder is lacking the '.pro' file.
Currently I'm using Qt 5.15.2 (via QT Creator) with MinGW Kit and cmake/ qbs.
As I'd like to play around with SQL-based apps.
Maybe I'm just skipping/ overlook something?
TL;DR: Use cmake. Forget about qbs and qmake.
Whenever I create a new project - doesn't matter whether its with qbs, qmake, or cmake - the project structure/ folder is lacking the '.pro' file.
A qmake project will have the .pro file, since that's the project file for qmake. Maybe you're looking in a wrong place? A qbs project will have a .qbs file, since that's what qbs uses. A cmake project will have CMakeLists.txt, since that's what cmake uses. It all works for me.
I'm just confused by all these guides stating that I have to add QT += widgets sql in the .pro file.
Those guides only apply when you use qmake, since .pro are qmake project files.
I suggest that you use cmake, as qbs is abandoned now, and there's no benefit to using Qt-specific qmake over the widely supported and continuously developed cmake.
Qt documentation covers the basics of how to use cmake to build Qt projects.
Qt support is provided natively by cmake, and it thus provides a comprehensive reference page.

How to build a project under the src directory of Qt?

I found a .pro file 5.12.1\Src\qtbase\src\plugins\platforms\windows\windows.pro and opened it in Qt Creator. After configuring a MingW kit, I tried to build the project. But I got this error;
error: vulkan/vulkan.h: No such file or directory
#include <vulkan/vulkan.h>
Do I need to configure something before building the project? I do not want the vulkan support, just want to compile it successfully. I remember if I build the whole Qt src, I need to run a command like "configure xxxxx" in the src directory. Now I do not want to build whole Qt, just this project. There is a line in windows.pro that seems related to this problem.
qtConfig(vulkan): QT += vulkan_support-private
How should I do to remove the need for the vulkan stuff in order to build it successfully?
Yes, you will need to configure things. I suggest you read up on Building Qt 5 from source to understand what is involved.

qmake subproject in CMake project

I've got a CMake based project with the following "design":
add_subdirectory(first_lib)
add_subdirectory(second_lib)
add_subdirectory(qt_application)
My question is - can I create a qt_application subproject as a qmake based? I think it will be much easier.
It it is impossible - how can I manage it in other way?
CMake is perfectly capable of building a Qt project. All of KDE uses CMake.
See Qt's documentation.

To add or not to add Qt Libs and Headers to the Project Directory

Does it make sense to add relevant Qt Libs and headers (opensource version) to a projects repository or should I just reference them from the sdk directory ?
I (alone) am developing a cross-platform (windows/linux) c++ application which, will be using a number of thirdparty opensource libraries including Qt, OpenCV, log4cpp to name a few.
I started off development in Qt Creator for convenience (speedy GUI creation). Currently I have the Qt Sdk installed on both Linux and Windows outside the project directory.
I'm planning to move to CMAKE to for better configurability, e.g out-of-source builds and independance from Qt Creator and I would like to have all dependencies included in the project directory structure -so that I or anyone else can checkout the project and build without needing to install any other dependancies.
I have added all libs but Qt's to the directory as I am a little unsure weather its worth it -it seems like CMAKE depends on the Qt Sdk for compiling Qt specific files i.e moc, ui etc... (see here) is this the case ? or is there a better suited build tool ? (Originally I was I going to use Scons but I decided not to as the there seemed to be limited support.. and there hasn't been developement on Qt4 Tools since 2010, which doesnt inspire confidence either.)
Qt is too big to be put in a project directory, even if you include only one of its modules. Also you have some convenient functions in CMake to use Qt (add moc, rcc, ui). You can even write these functions by yourself (in fast, they just add a pre-build command).
For the build operations: you will need to use the moc (and maybe ui, rcc, ...), which is not provided by CMake. So, a person wanting to build your application must have the Qt SDK installed. Luckily, this installation is very easy.

Is it possible to use Qt Creator without qmake?

I've heard that it is possible to build non-Qt applications (like simple C++ HelloWorld) with Qt Creator. I downloaded and installed Qt Creator, and tried to compile simple code with it. But I didn't succeed: Creator needs qmake to create makefile.
Although the package I downloaded includes MinGW, there is no qmake inside of it.
I still want to use it just like an IDE to create simple C++ sources and compile them with MinGW. Is it possible to use Qt Creator without installing whole platform?
Qt Creator support CMake projects, you just need to choose Open a file or project and select the root CMakeList.txt of your project.
If you want to define your own build workflow, you can remove the default build step and create your own custom build steps (Qt Creator Build Steps).
I think you can modify the build step to remove qmake and use your custom make file.
You totally can!
You can write a .pro file yourself and use it as a project file to use QtCreator without linking / using any of the Qt libraries.
In Project / Compilation Parameters, you can actually tune the compilation steps (removing the qmake step and adding your own).
I use it for a big project of mine and it's very efficient: QtCreator's C analyzer is diamond.
Here's a sample project file for me:
TEMPLATE = app
TARGET =
DEPENDPATH += . include
INCLUDEPATH += . include
# Input
HEADERS += include/x.h \
include/y.h \
include/z.h
SOURCES += src/x.cpp
Note that I actually use qmake to generate this file automatically, but you can also put your hands into it and modify it by hand.
Afterwards, it's only a matter of $ qtcreator yourfile.pro.