Application doesn't find Qt libraries during compilation process
-
I want to build hide console application (not visible components) but system tray icon. My application should use QSerialPort, networking and some else features. So I configure my pro file as follows:
QT -= gui CONFIG += c++11 console serialport network CONFIG -= app_bundle SOURCES += \ main.cpp RESOURCES += \ resources.qrcThe application won't build because tons of errors:
undefined reference to `_imp___ZN11QSerialPortC1EP7QObject' undefined reference to `_imp___ZN5QMenuC1EP7QWidget'and so on.
I seems like Qt libraries don't connected to the application.How to fix that?
-
I want to build hide console application (not visible components) but system tray icon. My application should use QSerialPort, networking and some else features. So I configure my pro file as follows:
QT -= gui CONFIG += c++11 console serialport network CONFIG -= app_bundle SOURCES += \ main.cpp RESOURCES += \ resources.qrcThe application won't build because tons of errors:
undefined reference to `_imp___ZN11QSerialPortC1EP7QObject' undefined reference to `_imp___ZN5QMenuC1EP7QWidget'and so on.
I seems like Qt libraries don't connected to the application.How to fix that?
-
QT += network widgets serialportModule names should be added/removed in
QT, notCONFIG.
And you need to addwidgetsfor QMenu since you removedgui.
[Added]
Ah, seemswidgetsdepends ongui, so adding widgets will add gui again. I guess you should not remove gui if you want use QMenu. -
QT += network widgets serialportModule names should be added/removed in
QT, notCONFIG.
And you need to addwidgetsfor QMenu since you removedgui.
[Added]
Ah, seemswidgetsdepends ongui, so adding widgets will add gui again. I guess you should not remove gui if you want use QMenu. -
I want to build hide console application (not visible components) but system tray icon. My application should use QSerialPort, networking and some else features. So I configure my pro file as follows:
QT -= gui CONFIG += c++11 console serialport network CONFIG -= app_bundle SOURCES += \ main.cpp RESOURCES += \ resources.qrcThe application won't build because tons of errors:
undefined reference to `_imp___ZN11QSerialPortC1EP7QObject' undefined reference to `_imp___ZN5QMenuC1EP7QWidget'and so on.
I seems like Qt libraries don't connected to the application.How to fix that?
@tankist said in Application doesn't find Qt libraries during compilation process:
system tray icon
It is not working like that...
QSysTrayIconis aQWidgetand therefore needs theQtWidgetmodule. Even though when your intention is to build a "background" app... The above mentioned class(es) (includingQMenuwhat you are probably gonna use as a popup when clicking the icon) requires some GUI components. -
Thank you, guys. It was just my mistake. Now configuration looks like
QT -= gui QT += serialport network widgets CONFIG += c++11 consoleand the application build process succeeded.
The only issue is widgets are not created. Application crashed onmenu = new QMenu();with error
QWidget: Cannot create a QWidget without QApplicationI have no idea what was wrong because I created QApplication object before.
int main(int argc, char *argv[]) { a = new QCoreApplication(argc, argv); sysMon = new SystemMonitor();Maybe it was wrong idea at all to create console application with system tray icon?
-
Thank you, guys. It was just my mistake. Now configuration looks like
QT -= gui QT += serialport network widgets CONFIG += c++11 consoleand the application build process succeeded.
The only issue is widgets are not created. Application crashed onmenu = new QMenu();with error
QWidget: Cannot create a QWidget without QApplicationI have no idea what was wrong because I created QApplication object before.
int main(int argc, char *argv[]) { a = new QCoreApplication(argc, argv); sysMon = new SystemMonitor();Maybe it was wrong idea at all to create console application with system tray icon?
@tankist said in Application doesn't find Qt libraries during compilation process:
Maybe it was wrong idea at all to create console application with system tray icon?
Yes, exactly! As @Pl45m4 already posted above.
AndQCoreApplicationis not aQApplication,QApplicationinheritsQGuiApplication,QGuiApplicationinheritsQCoreApplication.
So clearly you cannot use QMenu without gui. -
T tankist has marked this topic as solved on