Hi All....
I have written a simple Qt application and trying to build it with a makefile. But i am getting linker errors.
#include <QApplication>
#include <QDialog>
int main(int argc, char *argv[]){
dlg.show();
return app.exec();
}
#include <QApplication>
#include <QDialog>
int main(int argc, char *argv[]){
QApplication app(argc, argv);
QDialog dlg;
dlg.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Makefile:
CC=g++
CFLAGS=-c -Wall
LDFLAGS=
QTDIR=D:/Qt/2009.02/qt
LIB_PATH=-L"$(QTDIR)/lib"
LIBS=-lqtmaind -lQtGuid4 -lQtCored4
QT_INCLUDE=QtGui QtCore
INCLUDE=-I"." -I"$(QTDIR)/include" $(QT_INCLUDE:Qt=-ID:/Qt/2009.02/qt/include/Qt)
SOURCES=main.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LIB_PATH) $(LIBS) $(LDFLAGS) $(OBJECTS) -o $@
.cpp.o:
$(CC) $(CFLAGS) $< -o $@ $(INCLUDE)
clean:
# rm -rf $(TARGET)
rm -rf *.o
CC=g++
CFLAGS=-c -Wall
LDFLAGS=
QTDIR=D:/Qt/2009.02/qt
LIB_PATH=-L"$(QTDIR)/lib"
LIBS=-lqtmaind -lQtGuid4 -lQtCored4
QT_INCLUDE=QtGui QtCore
INCLUDE=-I"." -I"$(QTDIR)/include" $(QT_INCLUDE:Qt=-ID:/Qt/2009.02/qt/include/Qt)
SOURCES=main.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LIB_PATH) $(LIBS) $(LDFLAGS) $(OBJECTS) -o $@
.cpp.o:
$(CC) $(CFLAGS) $< -o $@ $(INCLUDE)
clean:
# rm -rf $(TARGET)
rm -rf *.o
To copy to clipboard, switch view to plain text mode
Error Log
Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
main.o(.text+0x182):main.cpp: undefined reference to `_imp___ZN12QApplicationC1ERiPPci'
main.o(.text+0x1c5):main.cpp: undefined reference to `_imp___ZN7QDialogC1EP7QWidget6QFlagsIN2Qt10Window TypeEE'
main.o(.text+0x1e1):main.cpp: undefined reference to `_imp___ZN12QApplication4execEv'
main.o(.text+0x1fe):main.cpp: undefined reference to `QDialog::~QDialog()'
main.o(.text+0x213):main.cpp: undefined reference to `QApplication::~QApplication()'
main.o(.text+0x25f):main.cpp: undefined reference to `QDialog::~QDialog()'
main.o(.text+0x28c):main.cpp: undefined reference to `QApplication::~QApplication()'
collect2: ld returned 1 exit status
NMAKE : fatal error U1077: 'D:\Qt\2009.02\mingw\bin\g++.EXE' : return code '0x1'
Stop.
Please help.
Regards,
Kamleshwar
Bookmarks