Results 1 to 4 of 4

Thread: Mac-specific issues for qmake and framework dependencies

  1. #1
    Join Date
    Nov 2007
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Mac-specific issues for qmake and framework dependencies

    My question concerns how to make my own frameworks and how to make applications that use these frameworks without using the install_name_tool on Mac OSX. My progress so far is quite good, but I am obviously not there yet and could really use help. This is all being developed on Mac OSX 10.6.4 with Qt 4.6.2 Open Source.

    I have developed a functional set of 4 shared libraries and many applications that use them on linux and windows without issue. My attempt to port it into mac has been nothing but a headache. I will try to present here a simplified example of the problem.

    MyLibA - .h and .cpp files for A-group functionality
    MyLibB- .h and .cpp files for B-group functionality (depends on MyLibA)

    MyApp - application that depends on both MyLibA/B.

    qmake.pri is a file included by all 3 pro files and for mac looks like this:
    Qt Code:
    1. QMAKE_COPY="cp -fp"
    2. isEmpty( TGT ) : error( You must set TGT for TARGET $${_FILE_} )
    3.  
    4. VERSION=4.1.0
    5. MY_LIB=/Library/Frameworks
    6.  
    7. A_LIB=MyLibA
    8. B_LIB=MyLibB
    9.  
    10. contains( TEMPLATE, lib ) {
    11. CONFIG += lib_bundle explicitlib
    12. DESTDIR = $${MY_LIB}
    13.  
    14. FRAMEWORK_HEADERS.version = Versions
    15. FRAMEWORK_HEADERS.files = $${HEADERS}
    16. FRAMEWORK_HEADERS.path = Headers
    17.  
    18. QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS
    19. QMAKE_FRAMEWORK_BUNDLE_NAME = $${TGT}
    20. QMAKE_FRAMEWORK_VERSION = $${VERSION}
    21. }
    22. contains( TEMPLATE, app ) {
    23. DESTDIR = /Applications
    24. TARGET=$${TGT}
    25. }
    26. MY_A_LIB=$${A_LIB}
    27. MY_A_INC=$${A_LIB}".framework/Headers"
    28. MY_B_LIB=$${B_LIB}
    29. MY_B_INC=$${B_LIB}".framework/Headers"
    30.  
    31. contains( CONFIG, alib ) {
    32. INCLUDEPATH += $${MY_LIB}/$${MY_A_INC}
    33. LIBS += -framework $${MY_A_LIB}
    34. }
    35. contains( CONFIG, blib ) {
    36. INCLUDEPATH += $${MY_LIB}/$${MY_B_INC}
    37. LIBS += -framework $${MY_B_LIB}
    38. }
    To copy to clipboard, switch view to plain text mode 

    Then both Lib qmake.pro files are like this:
    Qt Code:
    1. TEMPLATE=LIB
    2. TGT=MyLibA
    3.  
    4. #TGT=MyLibB
    5. #CONFIG += alib
    6.  
    7. HEADERS += a.h a2.h
    8. SOURCES += a.cpp a2.cpp
    9.  
    10. include( ../qmake.pri )
    To copy to clipboard, switch view to plain text mode 

    And MyApp has a pro file like this:
    Qt Code:
    1. TEMPLATE=APP
    2. TGT=MyApp
    3.  
    4. CONFIG += alib blib
    5.  
    6. HEADERS = myApp.h
    7. SOURCES = myApp.cpp main.cpp
    8.  
    9. include( ../qmake.pri )
    To copy to clipboard, switch view to plain text mode 

    Everyone compiles and installs into the proper locations and the issue is that I need to run install_name_tool on both the libraries and the application before it will successfully run.

    Qt Code:
    1. #inside /Library/Frameworks
    2.  
    3. install_name_tool -change MyLibA.framework/Versions/4.1.0/MyLibA /Library/Frameworks/MyLibA.frameworks/Versions/4.1.0/MyLibA /Library/Frameworks/MyLibA.frameworks/Versions/4.1.0/MyLibA
    4. install_name_tool -change MyLibA.framework/Versions/4.1.0/MyLibA /Library/Frameworks/MyLibA.frameworks/Versions/4.1.0/MyLibA /Library/Frameworks/MyLibB.frameworks/Versions/4.1.0/MyLibB
    5. install_name_tool -change MyLibB.framework/Versions/4.1.0/MyLibB /Library/Frameworks/MyLibB.frameworks/Versions/4.1.0/MyLibB /Library/Frameworks/MyLibB.frameworks/Versions/4.1.0/MyLibB
    6.  
    7. #inside /Applications
    8.  
    9. install_name_tool -change MyLibA.framework/Versions/4.1.0/MyLibA /Library/Frameworks/MyLibA.frameworks/Versions/4.1.0/MyLibA MyApp.app/Contents/MacOS/MyApp
    10. install_name_tool -change MyLibB.framework/Versions/4.1.0/MyLibB /Library/Frameworks/MyLibB.frameworks/Versions/4.1.0/MyLibB MyApp.app/Contents/MacOS/MyApp
    To copy to clipboard, switch view to plain text mode 

    Now I am praying that someone can help me fix this so that I do not have to run this install_name_tool as even with it all scripted up, it does not feel right and I assume I am still missing something...

    Thanks in advance -- and lots of names where changed to protect their identity and such, so if there are typos, it was done here in the forum, like I said, I can get it to work, I just cannot figure out how to get rid of the install_name_tool step.
    Last edited by jiaco; 9th July 2010 at 15:20.

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Mac-specific issues for qmake and framework dependencies

    I guess you will have to run install_name_tool in any case: Your application searches for the framework at some location: Either in /Library/Frameworks or inside the bundle. But even for searching inside the bundle, the path has to be adopted to something like @bundle_path.
    It's nice to be important but it's more important to be nice.

  3. #3
    Join Date
    Nov 2007
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Mac-specific issues for qmake and framework dependencies

    Thanks for the reply, I have now a bash script that will run otool and then install_name_tool and does the job fine, it is even applied through a command inside my qmake file.

    The only issue now is that after running qmake and make, I have to run make macinstall (the name of the target) as I have not been able to automate the process any further than that.

    I guess I sort of figured this must be a common problem and that I had overlooked something.

  4. #4
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Mac-specific issues for qmake and framework dependencies

    Just an idea to automate further:
    If you are using the subdirs-template in your topmost directory, you can include a directory that just contains a makefile. QMake will execute that makefile. This makefile could be used to trigger your macinstall-task.
    It's nice to be important but it's more important to be nice.

  5. The following user says thank you to axeljaeger for this useful post:

    jiaco (31st July 2010)

Similar Threads

  1. Issues with the Graphics View Framework
    By lni in forum Qt Programming
    Replies: 8
    Last Post: 26th April 2009, 14:13
  2. qmake project dependencies
    By akos.maroy in forum Newbie
    Replies: 1
    Last Post: 15th June 2008, 13:52
  3. Qmake + Xcode + Dependencies?
    By amnesiac in forum Qt Programming
    Replies: 3
    Last Post: 6th June 2008, 13:45
  4. Adding library dependencies to qmake
    By sadastronaut in forum Installation and Deployment
    Replies: 2
    Last Post: 18th March 2008, 17:06
  5. QMAKE: Specifying Build Dependencies
    By JohnSuykerbuyk in forum Qt Programming
    Replies: 1
    Last Post: 5th May 2006, 09:46

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.