Почему на следующий код ругается линкер:
class Q {
public:
static const int C = 0;
Q();
};
#include "inc.h"
#include <QtCore>
Q::Q() {
QVector<int> tt;
tt.append(C);
}
debug/inc.o(.text+0x14b): In function `ZN1QC2Ev':
D:/Workspaces/CppGeneWorkspace/ZTest2/src/inc.cpp:8: undefined reference to `Q::C'
debug/inc.o(.text+0x20d): In function `ZN1QC1Ev':
D:/Workspaces/CppGeneWorkspace/ZTest2/src/inc.cpp:8: undefined reference to `Q::C'
Собираю так:
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\qt4.3.3\include\QtCore" -I"c:\qt4.3.3\include\QtCore" -I"c:\qt4.3.3\include\QtGui" -I"c:\qt4.3.3\include\QtGui" -I"c:\qt4.3.3\include" -I"c:\qt4.3.3\include\ActiveQt" -I"debug" -I"." -I"c:\qt4.3.3\mkspecs\win32-g++" -o debug\inc.o src\inc.cpp
src\inc.cpp:9:2: warning: no newline at end of file
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\ZTest2.exe debug/inc.o debug/main.o -L"c:\qt4.3.3\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
mingw 4.3.2