Results 1 to 2 of 2

Thread: Linker error while building with a makefile

  1. #1
    Join Date
    Jul 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Linker error while building with a makefile

    Hi All....

    I have written a simple Qt application and trying to build it with a makefile. But i am getting linker errors.

    Qt Code:
    1. #include <QApplication>
    2. #include <QDialog>
    3.  
    4. int main(int argc, char *argv[]){
    5.  
    6. QApplication app(argc, argv);
    7. QDialog dlg;
    8. dlg.show();
    9. return app.exec();
    10.  
    11.  
    12. }
    To copy to clipboard, switch view to plain text mode 

    Makefile:

    Makefile Code:
    1. CC=g++
    2. CFLAGS=-c -Wall
    3. LDFLAGS=
    4.  
    5. QTDIR=D:/Qt/2009.02/qt
    6. LIB_PATH=-L"$(QTDIR)/lib"
    7. LIBS=-lqtmaind -lQtGuid4 -lQtCored4
    8. QT_INCLUDE=QtGui QtCore
    9. INCLUDE=-I"." -I"$(QTDIR)/include" $(QT_INCLUDE:Qt=-ID:/Qt/2009.02/qt/include/Qt)
    10.  
    11. SOURCES=main.cpp
    12. OBJECTS=$(SOURCES:.cpp=.o)
    13. EXECUTABLE=hello
    14.  
    15. all: $(SOURCES) $(EXECUTABLE)
    16.  
    17. $(EXECUTABLE): $(OBJECTS)
    18. $(CC) $(LIB_PATH) $(LIBS) $(LDFLAGS) $(OBJECTS) -o $@
    19.  
    20. .cpp.o:
    21. $(CC) $(CFLAGS) $< -o $@ $(INCLUDE)
    22.  
    23.  
    24. clean:
    25. # rm -rf $(TARGET)
    26. 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
    Last edited by wysota; 17th July 2009 at 23:08.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Linker error while building with a makefile

    Don't create your own Makefiles. change into the directory where your files are located, run qmake -project then qmake again and then (n)make.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. not able to change Makefile
    By shamik in forum Qt Programming
    Replies: 1
    Last Post: 9th June 2007, 12:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.