Results 1 to 8 of 8

Thread: QT Creator - Creating and Using LIBS

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QT Creator - Creating and Using LIBS

    Hi all,

    I know there has been related questions to this on the forums. I've searched through them but none of which answer my particular problem.

    Firstly, I'm a nooby, so go easy. I'm trying to learn c++ for myself and have chosen the following configuration to get started;
    OS: XP
    toolkit: QT 4.5.1
    IDE: QT Creator 1.2

    Everything is up and running and I've created some *basic* progs.

    However, I'm stuck on the following problem. I wanted to learn how to use libraries. So I created a shared library (called test2library) using the QT Creator wizard and added some silly functionality. Unfortunately, I'm not able to use the linked library in my main project (called imaginatively mainProject).

    // Please also let me know of any bad practice etc. As I said, I'm trying to learn here so all comments welcome in addition to the solution.//

    So my shared library contains four files; test2library.h .cpp .pro and _global.h

    Here are the changes I made to the header and implementation files.


    test2library.h
    Qt Code:
    1. #ifndef TEST2LIBRARY_H
    2. #define TEST2LIBRARY_H
    3.  
    4. #include "test2Library_global.h"
    5. #include <qDebug>
    6.  
    7. class TEST2LIBRARYSHARED_EXPORT Test2Library {
    8. public:
    9. Test2Library();
    10. void doit();
    11. };
    12.  
    13. #endif // TEST2LIBRARY_H
    To copy to clipboard, switch view to plain text mode 

    test2library.cpp
    Qt Code:
    1. #include "test2library.h"
    2.  
    3.  
    4. Test2Library::Test2Library()
    5. {
    6. }
    7.  
    8. void Test2Library::doit()
    9. {
    10. qDebug() << "In test2Library";
    11. }
    To copy to clipboard, switch view to plain text mode 

    OK, everything compiled OK and seems to be running.

    So I go back to my mainProject which is a GUI frame, also with some silly code in it. I open up my mainProject.pro and add the following lines;

    Qt Code:
    1. <snip>
    2.  
    3. INCLUDEPATH += "..\test2Library\test2library"
    4. win32:LIBS += -L"..\test2Library\test2library\debug" -ltest2Library
    To copy to clipboard, switch view to plain text mode 

    I save everything and rebuild...everything seems fine.

    Then in my mainProject I add the header;

    Qt Code:
    1. #include "../test2Library/test2library/test2library.h"
    2.  
    3. void MainWindow::on_pushButton_clicked()
    4. {
    5. qDebug() << "Button pressed!";
    6. Test2Library *t = new Test2Library();
    7. t->doit();
    8. }
    To copy to clipboard, switch view to plain text mode 

    The program builds fine, but when I run it, I get

    Qt Code:
    1. ..../mainProgram.exe exited with code -1073741515
    To copy to clipboard, switch view to plain text mode 

    Can anyone give me any helpful pointers. I've searched for solutions but can't seem to find anything that works. I've simplified the entire process as much as possible in order to isolate the problem. It seems that there is a problem with linking the libraries?

    Cheers,
    Mick
    Last edited by floyd.pepper; 22nd July 2009 at 05:34.

Tags for this Thread

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.