PDA

View Full Version : Embedding a custom DLL on Mac



sdfisher
26th March 2007, 20:38
I want to build a Qt project that uses another Qt project. I have (barely, and with little help from the docs) got this working with the embedded project as a static library, but want to make it work with dynamic libraries.

I figured the first step would be changing the staticlib in the library project to be dll. That's got the library compiling and linking again, although until I get something using it I'm not sure it's really working.

I removed the output statlic library and ran qmake on the application project, and that seems to compile and link. The result won't run, apparently because it can't find the library. I'm not sure where the library should be within the bundle, though.

Ideally, I'd like for the application project to build an application with the dylib output by the library project copied into the appropriate place in the application bundle.

Any tips?

Brandybuck
27th March 2007, 05:30
Ideally, I'd like for the application project to build an application with the dylib output by the library project copied into the appropriate place in the application bundle.
That's the easy part! :-) Just put them in the Frameworks directory. Even if they're not true frameworks, you can put them in there. See http://doc.trolltech.com/4.2/deployment-mac.html for more information.

The hard part, if you read the above link, is getting the application to find them. Apple has not made this easy. You need to get the application to point to the shared libraries, and for the shared libraries to point to each other (QtGui needs to know where to find QtCore, for example). The commands to do this are obtuse, so I wrote a script to do it. This assumes you are using the command line and makefiles, but it should easily be adapted for XCode use. I've put it up on the wiki at http://wiki.qtcentre.org/index.php?title=Mac_OSX_Deployment_Script

xgoan
27th March 2007, 13:27
I have tried the shell script and it works and creates the .dmg file.

But when moved the file to another Mac the QMYSQL driver is not found

xgoan
27th March 2007, 13:29
This script prepares a Qt application bundle for deployment. It will
copy over the required Qt frameworks and sets the installation
identifications. Please see the "Deploying an Application on Qt/Mac"
page in the Qt documentation for more information.

This script assumes you have already built the application bundle.

What is the name of the application? konstructor
application: konstructor
bundle: konstructor.app
Using frameworks QtSql QtGui QtCore
Running make install
make: Nothing to be done for `install'.
Copying QtSql framework
Copying QtGui framework
Copying QtCore framework
Setting framework IDs...Setting framework IDs... QtSql QtGui QtCore
Changing framework paths for konstructor... QtSql QtGui QtCore
Fixing bundled frameworks... QtSql QtGui QtCore
Creating disk image
.................................................. .................................................. .......................................
created: /Users/David/Desktop/konstructor/konstructor.dmg
hdiutil: internet-enable: enable succeeded
Done

The script output

sdfisher
27th March 2007, 19:48
Thanks! The only thing not clear to me at this point is if it is possible to have qmake build an Xcode project that automatically makes the Frameworks directory an d copies my framework to it. I'm content to have to copy the Qt frameworks there manually since they're always on my development system's search path and I only really need to copy them to deploy, but it's a greater pain with my custom library. Or would a better strategy to try to make my library project build to i.e. ~/Library/Frameworks?