Hi,

I have mainWindow.cpp and DialogWifi.cpp

In DialogWifi.cpp I connect to wifi. If connection successful I want to set once the global variable like globalShowWifiIcon and globalWifiConnect.
So I created separate globals.h and put the global variable as;

globals.h

Qt Code:
  1. #ifndef GLOBALS
  2. #define GLOBALS
  3.  
  4. namespace globals
  5. {
  6. // forward declarations only
  7. extern bool globalShowWifiIcon;
  8. extern bool globalWifiConnect;
  9. }
  10.  
  11. #endif // GLOBALS
To copy to clipboard, switch view to plain text mode 


In DialogWifi.cpp I try to set as;
Qt Code:
  1. globals::globalShowWifiIcon = true;
  2. globals::globalWifiConnect = true;
To copy to clipboard, switch view to plain text mode 

Then in MainWindow.cpp
Qt Code:
  1. if(globals::globalShowWifiIcon == false)
  2. {
  3. ui->labelLogo->setPixmap(QPixmap("/home/root/res/button/wifiOff.png"));
  4. }
  5. else
  6. {
  7. ui->labelLogo->setPixmap(QPixmap("/home/root/res/button/wifi.png"));
  8. }
To copy to clipboard, switch view to plain text mode 

In mainWindow.cpp and DialogWifi.cpp I incluede as;
Qt Code:
  1. #include "globals.h"
To copy to clipboard, switch view to plain text mode 

When I compile I am getting error as;

error: undefined reference to `globals::globalShowWifiIcon'

Any help please,

Kind Regards,