Qt Creator for shared library on Mac?
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;
- 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!
[EDIT: code formatting, please wrap in @-tags, Volker]
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?
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…