Linking libs on moved project from Win/VS 2022 to RaspbianOS/QtCreator
-
Hi all,
So I'm trying to move my project that includes some Qt libraries and also external one.
In VS I'm doing it like that in project's properties:
In C/C++->General->Additional Include Directories you must set the Qt installation include path;
In Linker->General->Additional Library Directories you must add the path of .libs files of your qt installation;
In Linker->Input->Additional Dependencies you must put the name of .lib files that you need in order to build the project.In QtCreator on RaspbianOS I have mostly issue with QtNetwork libraries for now when debugging, as I'm getting e.g. "undefined reference to 'QNetworkAccessManager (...)"
When moving I've just created the new Qt console project, copied my code and filled .pro file. I'm including in main.cpp like this:
#include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkRequest> #include <QtNetwork/QNetworkReply> #include <nlohmann/json.hpp>..and this is what I've added to .pro file:
INCLUDEPATH += /home/jakub/Downloads/json-develop/include INCLUDEPATH += /usr/include/i386-linux-gnu/qt5What did i miss?
-
You need to add the network module to your qmake project. In the .pro file there's a
QT +=line. Addnetworkthere and re-run qmake (from the Build menu). qmake will then add the necessary paths and libs to your build config.If you look at the documentation for Qt classes there's always information near the top what module you need for given class e.g.
QT += networkforQNetworkAccessManager -
You need to add the network module to your qmake project. In the .pro file there's a
QT +=line. Addnetworkthere and re-run qmake (from the Build menu). qmake will then add the necessary paths and libs to your build config.If you look at the documentation for Qt classes there's always information near the top what module you need for given class e.g.
QT += networkforQNetworkAccessManager@Chris-Kawa It solved the issue, thank you very much!
-
Sorry for writing here again, didn't want to start new topic. I've noticed that deleting/commenting std libraries changes nothing. I mean the program can be rebuild and normally works, e.g. removing #include <string> when I'm using lot of std::string variables is completely fine. How it happens, what part of code includes them?
-
It most probably gets included transitionally by some other headers. Most compilers have a switch to print out include hierarchy for compiled files, so you can use it and search for
/stringor/string.hin the compilation output pane.
For MSVC you would addQMAKE_CXXFLAGS += /showIncludesin the .pro file. GCC has similarQMAKE_CXXFLAGS += -Hoption.