Results 1 to 3 of 3

Thread: Using Qt to write Cross Platform Library

  1. #1
    Join Date
    Jan 2006
    Posts
    75
    Thanks
    3
    Thanked 5 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Using Qt to write Cross Platform Library

    is anybody know how to use Qt to write cross-platform class library(not a stand-alone program), to be called by other Qt program?

    that is, i can use QObject like QString inside the functions in my library, and still can be identify by other Qt program once it has been loaded by QLibrary

  2. #2
    Join Date
    Mar 2006
    Posts
    14
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Using Qt to write Cross Platform Library

    Yes, you can create a cross platform library, similar to any other library. What you should do is compile the library as normal on every platform and supply a header file with the definitions of the interface to the library (also as normal). By including that header file in the program, the classes/functions/etc in the library are known and the library can be linked to the program during linking.

    So, basically you need to create the following:
    libLinux.a
    libLinux64.a
    libSunOs.a
    libDefinitions.h

    We do this all the time, but then with modules in the development tree.

    You can also create a dynamic library, but I don't have any experience with that.

  3. #3
    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: Using Qt to write Cross Platform Library

    Add "TEMPLATE = lib" to your project file. If you want your library to be loadable by QLibrary, you also have to make sure that all functions in that library are declared as extern "C":

    Qt Code:
    1. extern "C" {
    2. void func1();
    3. void func2();
    4. void func3();
    5. //...
    6. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QT Creator, cross platform program.
    By kazek3018 in forum Newbie
    Replies: 8
    Last Post: 20th December 2008, 23:13
  2. Cross platform advice
    By tntcoda in forum Installation and Deployment
    Replies: 1
    Last Post: 15th October 2008, 17:58
  3. Crash handler on Win32
    By niko in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2007, 19:41
  4. Weird Cross Platform Printing Problems
    By igor in forum Qt Programming
    Replies: 7
    Last Post: 7th August 2007, 16:25
  5. Cross compile QT/X11 for platform xscale-elf
    By nmkarvekar in forum Installation and Deployment
    Replies: 0
    Last Post: 19th May 2006, 07:20

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.