Results 1 to 14 of 14

Thread: Some advice on how to structure this program?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2009
    Posts
    10
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Some advice on how to structure this program?

    Thanks for all the help but I am still having issues and its driving me nuts....

    as I understand it the libXXX.a file is the library containing all the classes and functions... I found http://doc.trolltech.com/4.5/qmake-v...ence.html#libs and its helped me out a bit but I still cant get it to work

    In my .pro file of the GUI app I have LIBS += -L"C:/Documents and Settings/......../c++/disspertionLib/release" -ldisspertionLib

    the folder release contains all the .o and libxxx.a files

    but I am still getting errors:

    mainwindow.cpp:7:24: coordinate.h: No such file or directory
    mainwindow.cpp:8:25: boundaryMap.h: No such file or directory
    mainwindow.cpp:9:22: particle.h: No such file or directory
    mainwindow.cpp: In member function `void MainWindow:n_btnGo_clicked(bool)':
    mainwindow.cpp:53: error: `boundaryMap' was not declared in this scope
    mainwindow.cpp:53: error: expected `;' before "bound"
    mainwindow.cpp:55: error: `Particle' was not declared in this scope

    etc......


    btw... how do I include the library in my code? At the moment I still have
    #include "coordinate.h"
    #include "boundaryMap.h"
    #include "particle.h"

    which were the origional names of the files before I put them into the library... do these still stay the same or do I need to change them?

    Thanks again

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Some advice on how to structure this program?

    Quote Originally Posted by mrwooster View Post
    btw... how do I include the library in my code? At the moment I still have
    You have to update INCLUDEPATH variable in .pro file.
    For example, your header files are in XXX folder.
    Write this line in your .pro file:
    Qt Code:
    1. INCLUDEPATH += XXX
    To copy to clipboard, switch view to plain text mode 
    Then your GUI program will be able to locate your header files.

    Using Static Libs Example:
    Suppose:
    I have 2 libs testLib1 and testLib2.
    These files are in user/local/libs.
    And header files of these libs are in user/local/headers.

    This is how my GUI application .pro file will look like.
    Qt Code:
    1. INCLUDEPATH += [B]user/local/headers[/B]
    2. LIBS += -L[B]user/local/libs[/B]
    3. LIBS += -l[B]testLib1[/B] -l[B]testLib2[/B]
    To copy to clipboard, switch view to plain text mode 

  3. The following 2 users say thank you to yogeshgokul for this useful post:

    mrwooster (12th August 2009), waynew (16th January 2010)

  4. #3
    Join Date
    Aug 2009
    Posts
    10
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Some advice on how to structure this program?

    Ah... thank you... I have finally managed to get it to compile and run.

    I created a folder libs and libs/headers to put the files in and it compiles and runs correctly....

    However, if I make any changes to disspertionLib then I have to re-compile my GUI program to get it to accept the changes.... is there any way around this? Or would that mean having to use dynamic linking?

    BTW.. thanks for you help.... its been really great!

  5. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Some advice on how to structure this program?

    Quote Originally Posted by mrwooster View Post
    However, if I make any changes to disspertionLib then I have to re-compile my GUI program to get it to accept the changes.... is there any way around this? Or would that mean having to use dynamic linking?
    You are right. if you are working with static libs, then you have to re-compile user program also. Otherwise go for dynamic lib. But in dynamic libs, there are many more issues, like exporting, importing, symbol resolution, library loading.

  6. #5
    Join Date
    Aug 2009
    Posts
    10
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Some advice on how to structure this program?

    AH!!!!! Finally!! It is working as I wanted it....

    This is how I did it:

    I removed the CONFIG += staticlib from the .pro file of my library.... this then compiled it into a dll..... not a .a file

    I placed the disspertion.dll in a folder named libs and the header files in libs/headers

    the .pro file for my GUI looks like this:

    INCLUDEPATH = "C:/........./c++/libs/headers"
    LIBS += -L"C:/........./c++/libs"
    LIBS += -ldisspertionLib

    And it compiles fine.

    I then copied the disspertionLib.dll into the folder containing the .exe of the GUI application and it runs fine....

    If I change anything in disspertionLib and re-compile the dll.... I just copy it back into the directory of the GUI .exe and the changes are shown when I run the GUI without having to re-compile it....

    Seems to work fine.... is this an acceptable way of doing it? I had the impression that implementing .dll s was supposed to be much more complicated?

  7. #6
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Some advice on how to structure this program?

    You can do one more thing.
    Set the TARGETPATH of your dll's .pro file. Then it will automatically generate dll in your exe path. So you doesn't need to copy and paste again and again.

  8. The following user says thank you to yogeshgokul for this useful post:

    mrwooster (12th August 2009)

  9. #7
    Join Date
    Aug 2009
    Posts
    10
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Some advice on how to structure this program?

    Thanks... thats a good idea....

    Just out of interest... how come I can use a dll like this? I thought that a dll required a much more complicated setup procedure and calling functions from dlls required setting up pointers etc... and using the windows API?

    Ty

  10. #8
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Some advice on how to structure this program?

    Quote Originally Posted by mrwooster View Post
    how come I can use a dll like this? I thought that a dll required a much more complicated setup procedure and calling functions from dlls required setting up pointers etc... and using the windows API?
    Ty
    This is a big topic, please google some docs for dynamic libraries. There is adequate information available.
    QLibrary is used to load DLLs and resolve any symbol from DLL.

  11. The following user says thank you to yogeshgokul for this useful post:

    mrwooster (12th August 2009)

Similar Threads

  1. Program crashes on creating new dialog
    By eekhoorn12 in forum Qt Programming
    Replies: 2
    Last Post: 11th June 2009, 11:52
  2. Eclipse Integration and program not starting
    By Cruz in forum Installation and Deployment
    Replies: 1
    Last Post: 16th January 2009, 22:32
  3. Replies: 19
    Last Post: 21st January 2008, 09:13
  4. Version setting in QT Program
    By sabeesh in forum Qt Programming
    Replies: 4
    Last Post: 24th October 2007, 12:07
  5. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19

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
  •  
Qt is a trademark of The Qt Company.