title: Qt Problems compiling using an extern variable
body: <p>I have a rellly long process that produces about 700 Mb of a txt log output file. This is very hard to manage. So I want to divide the output in multiple smaller log files. This is what my main.cpp looks like</p>
  
  <pre><code>#include &lt;QtGui/QApplication&gt;
  #include "mineedit.h"
  #include "logoutput.h"
  #include &lt;iostream&gt;
  
  void messageHandling(QtMsgType type, const char *msg){
  
  if (ERRORLOGGER.isEmpty()){
      ERRORLOGGER = DEFERRORLOGGER;
  }
  
  std::cout &lt;&lt; "In Message Handling" &lt;&lt; std::endl;
  std::cout &lt;&lt; "Writing to file" &lt;&lt; ERRORLOGGER.toStdString() &lt;&lt; std::endl;
  
  QFile file(ERRORLOGGER);
  file.open(QFile::Append);
  QTextStream stream(&amp;file);
  switch (type) {
  case QtDebugMsg:
      stream &lt;&lt; msg &lt;&lt; "\n";
      file.close();
      break;
  case QtWarningMsg:
      stream &lt;&lt; "WARNING: " &lt;&lt; msg &lt;&lt; "\n";
      file.close();
      break;
  case QtCriticalMsg:
      stream &lt;&lt; "CRITICAL: " &lt;&lt; msg &lt;&lt; "\n";
      file.close();
      break;
  case QtFatalMsg:
      stream &lt;&lt; "FATAL: " &lt;&lt; msg &lt;&lt; "\n";
      file.close();
      abort();
  }    
  }
  
  int main(int argc, char *argv[])
   {
  ERRORLOGGER = DEFERRORLOGGER;
  qInstallMsgHandler(messageHandling);
  QApplication a(argc, argv);
  MineEdit w;
  w.show();
  return a.exec();
  }
  [/CODE]
  </code></pre>
  
  <p>And my logoutput.h is like</p>
  
  <pre><code>#ifndef LOGOUTPUT_H
  #define LOGOUTPUT_H
  
  #include &lt;QString&gt;
  
  //----------------------------For outputting an error file------------------------------
  #define         DEFERRORLOGGER             "/home/aarelovich/Documents/log.err"
  #define         FOLDER_OUTPUT_LOG          "./home/aarelovich/Documents"
  extern QString  ERRORLOGGER;
  
   #endif // LOGOUTPUT_H
  </code></pre>
  
  <p>Now in a part of my code I do:
      ERRORLOGGER = name_of_current_log_file.</p>
  
  <p>However I get the following compilation errors:
  obj/main.o: In function <code>messageHandling(QtMsgType, char const*)':
  /home/aarelovich/Dropbox/MineSim/main.cpp:8: undefined reference to</code>ERRORLOGGER'
  /home/aarelovich/Dropbox/MineSim/main.cpp:9: undefined reference to <code>ERRORLOGGER'
  /home/aarelovich/Dropbox/MineSim/main.cpp:13: undefined reference to</code>ERRORLOGGER'
  /home/aarelovich/Dropbox/MineSim/main.cpp:15: undefined reference to <code>ERRORLOGGER'
  obj/main.o: In function</code>main':
  /home/aarelovich/Dropbox/MineSim/main.cpp:40: undefined reference to <code>ERRORLOGGER'
  obj/mineedit.o:/home/aarelovich/Dropbox/MineSim/mineedit.cpp:101: more undefined references to</code>ERRORLOGGER' follow
  collect2: ld returned 1 exit status</p>
  
  <p>Can anyone please tell me what am I doing wrong? Or how I can dynamically change the output file in which I create my application log?</p>
  
  <p>Thanks for any help</p>