Results 1 to 5 of 5

Thread: A problem about "undefined reference to `Clean::Clean(QObject*)'

  1. #1
    Join Date
    Feb 2013
    Posts
    8
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default A problem about "undefined reference to `Clean::Clean(QObject*)'

    Hello experts.
    This is my project. It's a Symbian project:

    .PRO:

    Qt Code:
    1. folder_01.source = qml/GCleaner
    2. folder_01.target = qml
    3. DEPLOYMENTFOLDERS = folder_01
    4. symbian:TARGET.CAPABILITY += NetworkServices
    5. CONFIG += qt
    6. CONFIG += qt-components
    7. SOURCES += main.cpp
    8. QT += declarative
    9. files.sources += main.qml
    10. DEPLOYMENT += files
    11. include(qmlapplicationviewer/qmlapplicationviewer.pri)
    12. qtcAddDeployment()
    To copy to clipboard, switch view to plain text mode 

    CPP:

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "qmlapplicationviewer.h"
    3. #include <QObject>
    4. #include <QApplication>
    5. #include <QDeclarativeView>
    6. #include <QDeclarativeContext>
    7. #include <QDir>
    8. #include <QFile>
    9.  
    10. void deleteDir(const std::string& foldername)
    11. {
    12.  
    13. QDir dir;
    14. dir.rmdir(foldername.c_str());
    15. }
    16.  
    17. class Clean : public QObject {
    18. Q_OBJECT
    19. public:
    20. Clean(QObject *parent = 0);
    21.  
    22. Q_INVOKABLE void delete() {
    23. deleteDir(c:/temp)
    24. };
    25.  
    26. int main(int argc, char *argv[])
    27. {
    28. QApplication app(argc, argv);
    29.  
    30. Clean clean;
    31.  
    32. QDeclarativeView view;
    33. view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
    34. view.rootContext()->setContextProperty("Clean", &clean);
    35. view.setSource(QUrl("./main.qml"));
    36.  
    37. return app.exec();
    38. }
    To copy to clipboard, switch view to plain text mode 

    QML:

    Qt Code:
    1. import QtQuick 1.1
    2. import com.nokia.symbian 1.1
    3.  
    4. Window {
    5. id: window
    6. Button {
    7. id:button
    8. onClicked: Clean.delete
    9. } }
    To copy to clipboard, switch view to plain text mode 


    It tells me that "undefined reference to `Clean::Clean(QObject*)' " and "undefined reference for `vtable for Clean'
    I'm building this app for Symbian and I'm stuck at that. Please help me out.

    My best regards,
    George Dao.

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: A problem about "undefined reference to `Clean::Clean(QObject*)'

    In Clean constructor defined?

    Also it's a very good practice to write QObject derived classes in it's own header and cpp, else you need to include the .moc generated file for your QObjec derived class.

  3. The following user says thank you to Zlatomir for this useful post:

    GeorgeDao123 (8th February 2013)

  4. #3
    Join Date
    Feb 2013
    Posts
    8
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: A problem about "undefined reference to `Clean::Clean(QObject*)'

    Thanks for your help. It's highly appreciated.

    Sorry but my English is poor, and I'm so new to Qt. In my country there's no centre teaching Qt, so I have to learn it myself. You can call me "a noob". This is also my first Qt project ever made.

    I believe Clean constructor is defined. I did everything similar to this sample project from Nokia Dev page:
    But it doesn't work.

    By the way, the problem is at .CPP file, line 30.

    Could you please help me more? Thank you so much for that.

    My best regards,
    George Dao.
    Last edited by GeorgeDao123; 8th February 2013 at 13:55.

  5. #4
    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: A problem about "undefined reference to `Clean::Clean(QObject*)'

    Quote Originally Posted by GeorgeDao123 View Post
    I believe Clean constructor is defined.
    If you didn't define it in a separate file that you didn't post here then I believe the constructor is not defined, only declared. And based on the project file that you posted I believe main.cpp is your only C++ file (apart qmlapplicationviewer) thus I believe there are no other files in your project where you might have defined the constructor. This is basic C++ stuff, nothing Qt related.
    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.


  6. #5
    Join Date
    Feb 2013
    Posts
    8
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: A problem about "undefined reference to `Clean::Clean(QObject*)'

    Quote Originally Posted by wysota View Post
    If you didn't define it in a separate file that you didn't post here then I believe the constructor is not defined, only declared. And based on the project file that you posted I believe main.cpp is your only C++ file (apart qmlapplicationviewer) thus I believe there are no other files in your project where you might have defined the constructor. This is basic C++ stuff, nothing Qt related.
    Thank you so much for your help. I'll follow your instruction.

Similar Threads

  1. Replies: 2
    Last Post: 27th July 2011, 05:24
  2. Replies: 10
    Last Post: 9th September 2010, 17:43
  3. Replies: 0
    Last Post: 15th November 2009, 10:40
  4. Replies: 3
    Last Post: 11th January 2009, 06:22
  5. Qmake DLLDESTDIR, Visual Studio "clean solution"
    By SiLiZiUMM in forum Installation and Deployment
    Replies: 4
    Last Post: 18th March 2008, 13:14

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.