Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator for shared library on Mac?
Forum Updated to NodeBB v4.3 + New Features

Qt Creator for shared library on Mac?

Scheduled Pinned Locked Moved Qt Creator and other tools
8 Posts 4 Posters 5.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bovilexic
    wrote on last edited by
    #1

    Greetings -

    I have an existing Qt application that compiles on both Mac and PC with Qt Creator. With the help of the Qt plugin for Visual Studio 2008, I have created a VS 2008 project for the application. The intention was ultimately to create a shared library, and I was able to change the VS 2008 project from creating an application to a shared library by simply changing the project type to produce a dll file instead of an exe (via the project properties).

    As usual with Qt applications, the "main" entry point simply creates a QApplication, shows the main window (widget) and execs it:

    @
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MyWindow w;
    w.show();
    return a.exec();
    }
    @

    In VS 2008, I was able to turn this into a DLL by simply changing the project type to dll from exe, and changing the suffix accordingly. By adding code for a function that's known by another program, that other program can load the dll, and execute the function. That entry point simply does just what main() does, and so the host program launches the app as a "plugin".

    So far, so good, eh?

    Well, now I'd like to do the same thing on a Macintosh. Of course, the same source compiles under Qt Creator on the Mac. But although I've done some XCode and Qt Creator application programming on the Mac, I just don't know where to begin. I don't really care if I use XCode or Qt Creator for development, but I basically just need a project that creates a shared library (a dylib) from the source code for the application, and add the few entry points that the host program can call, and again simply launch QApplication, show the main window (dialog), and exec.

    Should be pretty simple, but documentation is sparse, and web searching just leads down a lot of rat-holes...

    Any help/advice/example projects (either XCode or Creator) would be most welcome!

    Thanks!

    -- Philip

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      main() is reserved as the entry point of an application. So it makes no sense to have that in a library. This will not work.

      I think window lets you get away with that since it internally uses some other method to start up your application.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        loladiro
        wrote on last edited by
        #3

        There is a template/wizard for creating shared libraries within Qt Creator, have a look at that (File -> New File or Project -> Other Project -> C++ library)

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          If you use qmake, just change the template from app (the default) to lib. See the "qmake docs":http://developer.qt.nokia.com/doc/qt-4.7/qmake-project-files.html#id-40996081-42f2-4221-99c8-c97ec528cc7e and the "qmake tutorial":http://developer.qt.nokia.com/doc/qt-4.7/qmake-tutorial.html for detailed information.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • B Offline
            B Offline
            bovilexic
            wrote on last edited by
            #5

            Hello and thank you for the responses!

            I have had success with this by using Qt Creator to make a shared library project, and then using qmake to create an equivalent XCode project....XCode 3, that is.

            I will have to try to see what happens in XCode 4, but I have heard that it's not quite working?

            Again, thanks!

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              You can use Qt Creator on all platforms of course ;-)

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • B Offline
                B Offline
                bovilexic
                wrote on last edited by
                #7

                Yes, I would like to have just gone with Qt Creator. Originally, I was unable to make the plugin link with the application. Turns out it was a 32-bit app, and Qt Creator insisted on making a 64-bit library. Figured that out sometime after I switched to XCode. Probably will go back and sort it out with Qt Creator, as it's rather a bit nicer than XCode in some ways, with regard to Qt coding... :-)

                Now that the 32- vs 64-bit issue is sorted out, I'll probably go back and try Qt Creator again for this project...

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tobias.hunger
                  wrote on last edited by
                  #8

                  Well, we can not really guess at the word size used in an application you want to link against the library you develop with Qt Creator:-)

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved