Question

This is best explained by the code itself. I want to use a QList<MyStruct> as a static member, but get a linker error 2001 (LNK2001). The code is in the same order in file MyClass.h

struct MyStruct{
    double  x;
    ...
};
typedef QList<MyStruct> MyStructList;

class MyClass
{
....
private:
    static MyStructList _myValues; // does not work => LNK2001
           MyStructList _myValues; // Test 1 OK
    static QList<int> _myValues; // Test 2 OK

Any hints? Eran's answer (see comment below) is the right hint. SOLVED

LNK2001:
error: LNK2001: unresolved external symbol "private: static class QList<struct> 
Was it helpful?

Solution

Yet another case of forgotten static member definition... MyStructList MyClass::_myValues should have been placed in one of the project's .cpp files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top