simple problem for your guys

i'm getting the following errors when i run this simple program...the application is supposed to close if the user types "nice" in the LineEdit and clicks the quit button, i'm also very new to Qt...i have a huge proj coming up due in April. Can you guys help me?

nice error LNK2001: unresolved external symbol "public: virtual bool __thiscall Checker::qt_emit(int,struct QUObject *)" (?qt_emit@Checker@@UAE_NHPAUQUObject@@@Z)
nice error LNK2001: unresolved external symbol "public: virtual bool __thiscall Checker::qt_invoke(int,struct QUObject *)" (?qt_invoke@Checker@@UAE_NHPAUQUObject@@@Z)
nice error LNK2001: unresolved external symbol "public: virtual bool __thiscall Checker::qt_property(int,int,class QVariant *)" (?qt_property@Checker@@UAE_NHHPAVQVariant@@@Z)
nice error LNK2001: unresolved external symbol "public: virtual char const * __thiscall Checker::className(void)const " (?className@Checker@@UBEPBDXZ)
nice error LNK2001: unresolved external symbol "public: virtual void * __thiscall Checker::qt_cast(char const *)" (?qt_cast@Checker@@UAEPAXPBD@Z)
nice error LNK2019: unresolved external symbol "public: static class QMetaObject * __cdecl Checker::staticMetaObject(void)" (?staticMetaObject@Checker@@SAPAVQMetaObject@@XZ) referenced in function "public: virtual class QMetaObject * __thiscall Checker::metaObject(void)const " (?metaObject@Checker@@UBEPAVQMetaObject@@XZ)
nice fatal error LNK1120: 6 unresolved externals



class Checker : public QObject
public slots:

void on_text_Change ( const QString& str )
if (str == "nice")//allow_quit = ( str == "nice" );
allow_quit = true;
void on_button_click()
if ( allow_quit )

void quit();
bool allow_quit;

int main( int argc, char **argv )
QApplication a( argc, argv );

QPushButton *quit = new QPushButton( "Quit", 0, "quit" );

QLineEdit *line = new QLineEdit( QString("nice"),0,0 );

Checker chk;
QObject::connect( line, SIGNAL(textChanged(const QString&)), &chk, SLOT(on_text_Change(const QString&)) );
QObject::connect( quit, SIGNAL(clicked()), &chk, SLOT(on_button_click()) );
QObject::connect( &chk, SIGNAL(quit()), &a, SLOT(quit()) );

a.setMainWidget( line );
return a.exec();

Sharjith Naramparambath's picture

This seems to be a link error i.e. before you get the executable to run???? how did you run the application ..... you say "when i run this simple program". Did you generate appropriate .pro file and Makefile using qmake tool. That should solve the problem by adding appropriate link path and include path to the compiling command line. Moreover, I suggest you to put the class interface for Checker in Checker.h, definition in Checker.cpp and the main stuff in main.cpp all under one folder called checker. Now run 'qmake -project' command. This will create a file in the folder. i.e. if you do ls, you see Checker.h, Checker.cpp, main.cpp and in your checker folder. Now just give 'qmake' command in shell and a Makefile is generated i.e. you see a new file called Makefile also in the same folder. Now give 'make' command. And after compiling you see the executable called checker in the folder which you can run. Note...qmake -project reads all the files in the current folder and generates a .pro file with same name as the 'pwd'. It also adds appropriate moc compiling actions if it encounters Q_OBJECT macro in any of the files. Your errors seem to be related to the meta object funda used by Qt. Read the Qt Documentation for more details. I hope this would help..

N. Sharjith

François Lauzon's picture

Hello Christopher,
you probably forgot to compile and link the moc file for your Checker class. Look at Qt documentation to know what to do if you don't know what I mean, since it's quite fundamental to Qt, you should learn about it.

Good Luck,