title: Error: LNK2001: unresolved external symbol "private: static class
body: <p>This forum contains many examples of such situation, but in my case static variables are defined correctly, however I still get that error. So this issue is not duplicate of previous and above link does not answer the question. Suggested <a href="https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix">21 answers post</a> does not have solution Simon gave me here, please unmark this as "duplicate".</p>
  
  <p>Seems I've declared all correctly, check this:</p>
  
  <p>.h file:</p>
  
  <pre><code>class ValueSetsModelsContainer : public QObject
  {
    Q_OBJECT
  
  public:
    static void DLLEXPORT loadAllergiesValueSets(MPTDatabase *db);
    static void DLLEXPORT loadProceduresValueSets(MPTDatabase *db);
  
    // Models access functions
    static QStandardItemModel *drugsModel();
    static QStandardItemModel *substanceModel();
    static QStandardItemModel *reactionsModel();
  
  private:
    static QStandardItemModel *myDrugsModel, *mySubstanceModel, *myReactionsModel;
  };
  </code></pre>
  
  <p>.cpp:</p>
  
  <pre><code>QStandardItemModel *ValueSetsModelsContainer::myDrugsModel = 0;
  QStandardItemModel *ValueSetsModelsContainer::mySubstanceModel = 0;
  QStandardItemModel *ValueSetsModelsContainer::myReactionsModel = 0;
  
  QStandardItemModel *ValueSetsModelsContainer::drugsModel()
  {
    return ValueSetsModelsContainer::myDrugsModel;
  }
  
  QStandardItemModel *ValueSetsModelsContainer::substanceModel()
  {
    return ValueSetsModelsContainer::mySubstanceModel;
  }
  
  QStandardItemModel *ValueSetsModelsContainer::reactionsModel()
  {
    return ValueSetsModelsContainer::myReactionsModel;
  }
  </code></pre>
  
  <p>So static variables are defined in cpp, however I still get linking error in another module which calls ValueSetsModelsContainer methods:</p>
  
  <blockquote>
    <ul>
    <li>allergiesdialog.obj:-1: error: LNK2001: unresolved external symbol
    "private: static class QStandardItemModel *
    ValueSetsModelsContainer::myDrugsModel"
    (?myDrugsModel@ValueSetsModelsContainer@@0PAVQStandardItemModel@@A)</li>
    <li>allergiesdialog.obj:-1: error: LNK2001: unresolved external symbol    "private: static class QStandardItemModel *<br>
    ValueSetsModelsContainer::mySubstanceModel"<br>
    (?mySubstanceModel@ValueSetsModelsContainer@@0PAVQStandardItemModel@@A)</li>
    <li>allergiesdialog.obj:-1: error: LNK2001: unresolved external symbol    "private: static class QStandardItemModel *<br>
    ValueSetsModelsContainer::myReactionsModel"<br>
    (?myReactionsModel@ValueSetsModelsContainer@@0PAVQStandardItemModel@@A)</li>
    </ul>
  </blockquote>
  
  <p>Where the problem could be?</p>