Results 1 to 2 of 2

Thread: Linking error when using library in other application

  1. #1
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Linking error when using library in other application

    Hi

    I've been trying to get my head around a linking error for a couple of days now. I have a library which has a QMainWindow derived class. The library builds fine, but when I create an instance of the derived class in a simple example program, the linker fails with the error below. I know what this error means, but I don't see how it applies to my situation:

    Qt Code:
    1. ../../tmp/actionmanagementexample/main.o: In function `Z5qMainiPPc':
    2. d:\ScinericSoftware\Products\Qtilities\trunk\libraries\ObjManagementLib\examples\ActionManagement/main.cpp:31: undefined reference to `Qtilities::ObjManagement::ExtendedMainWindow::ExtendedMainWindow(QWidget*)'
    To copy to clipboard, switch view to plain text mode 

    Here is my main program:

    Qt Code:
    1. #include <QtGui>
    2. #include <ExtendedMainWindow.h>
    3.  
    4. using namespace Qtilities::ObjManagement;
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9.  
    10. ExtendedMainWindow* mainWindow = new ExtendedMainWindow(0);
    11. mainWindow->show();
    12.  
    13. return a.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

    and my .pro file:

    Qt Code:
    1. TARGET = ActionManagement
    2. TEMPLATE = app
    3. SOURCES += main.cpp
    4. LIBS += ../../bin/libObjManagementLib.a
    5. CONFIG += debug
    To copy to clipboard, switch view to plain text mode 

    And the ExtendedMainWindow class:

    Qt Code:
    1. #ifndef OBJMANGEMENTLIBMAINWINDOW_H
    2. #define OBJMANGEMENTLIBMAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5.  
    6. namespace Ui {
    7. class ExtendedMainWindow;
    8. }
    9.  
    10. namespace Qtilities {
    11. namespace ObjManagement {
    12. struct ExtendedMainWindowData;
    13. class ExtendedMainWindow : public QMainWindow {
    14. Q_OBJECT
    15. public:
    16. ExtendedMainWindow(QWidget *parent = 0);
    17. ~ExtendedMainWindow();
    18.  
    19. protected:
    20. void changeEvent(QEvent *e);
    21.  
    22. private:
    23. Ui::ExtendedMainWindow *ui;
    24. ExtendedMainWindowData* d;
    25. };
    26. }
    27. }
    28.  
    29. #endif // OBJMANGEMENTLIBMAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    And the .cpp implementation of ExtendedMainWindow:

    Qt Code:
    1. #include "ExtendedMainWindow.h"
    2. #include "ui_ExtendedMainWindow.h"
    3.  
    4. struct Qtilities::ObjManagement::ExtendedMainWindowData {
    5. ExtendedMainWindowData() { }
    6.  
    7. };
    8.  
    9. Qtilities::ObjManagement::ExtendedMainWindow::ExtendedMainWindow(QWidget *parent) :
    10. QMainWindow(parent),
    11. ui(new Ui::ExtendedMainWindow)
    12. {
    13. ui->setupUi(this);
    14. d = new ExtendedMainWindowData;
    15. }
    16.  
    17. Qtilities::ObjManagement::ExtendedMainWindow::~ExtendedMainWindow()
    18. {
    19. delete ui;
    20. delete d;
    21. }
    22.  
    23. void Qtilities::ObjManagement::ExtendedMainWindow::changeEvent(QEvent *e)
    24. {
    25. QMainWindow::changeEvent(e);
    26. switch (e->type()) {
    27. case QEvent::LanguageChange:
    28. ui->retranslateUi(this);
    29. break;
    30. default:
    31. break;
    32. }
    33. }
    To copy to clipboard, switch view to plain text mode 

    The UI file is just a plain QMainWindow with nothing on it, called ExtendedMainWindow. I don't understand how the library is able to build (which means that it find the implementation of those functions), but linking against it does not work. Creating wit

    Any ideas will be greatly appreciated.

    Thanks,
    Jaco

  2. #2
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Re: Linking error when using library in other application

    Ah! Always happens, just when you post something you find the problem...

    Apologies, I forgot to export the class.
    Thanks
    Jaco

Similar Threads

  1. Linking Qt in a dynamic library
    By dave_mm0 in forum Qt Programming
    Replies: 4
    Last Post: 18th July 2009, 16:28
  2. Help needed linking to library
    By StephenR in forum Qt Programming
    Replies: 4
    Last Post: 3rd July 2009, 08:50
  3. Replies: 1
    Last Post: 16th September 2008, 17:29
  4. linking qt3 to a library
    By thebra in forum Newbie
    Replies: 10
    Last Post: 11th November 2006, 01:25
  5. import library linking
    By bruce1007 in forum Qt Programming
    Replies: 6
    Last Post: 19th May 2006, 10:27

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.