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:
QMAKE_COPY="cp -fp"
isEmpty( TGT ) : error( You must set TGT for TARGET $${_FILE_} )
VERSION=4.1.0
MY_LIB=/Library/Frameworks
A_LIB=MyLibA
B_LIB=MyLibB
contains( TEMPLATE, lib ) {
CONFIG += lib_bundle explicitlib
DESTDIR = $${MY_LIB}
FRAMEWORK_HEADERS.version = Versions
FRAMEWORK_HEADERS.files = $${HEADERS}
FRAMEWORK_HEADERS.path = Headers
QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS
QMAKE_FRAMEWORK_BUNDLE_NAME = $${TGT}
QMAKE_FRAMEWORK_VERSION = $${VERSION}
}
contains( TEMPLATE, app ) {
DESTDIR = /Applications
TARGET=$${TGT}
}
MY_A_LIB=$${A_LIB}
MY_A_INC=$${A_LIB}".framework/Headers"
MY_B_LIB=$${B_LIB}
MY_B_INC=$${B_LIB}".framework/Headers"
contains( CONFIG, alib ) {
INCLUDEPATH += $${MY_LIB}/$${MY_A_INC}
LIBS += -framework $${MY_A_LIB}
}
contains( CONFIG, blib ) {
INCLUDEPATH += $${MY_LIB}/$${MY_B_INC}
LIBS += -framework $${MY_B_LIB}
}
QMAKE_COPY="cp -fp"
isEmpty( TGT ) : error( You must set TGT for TARGET $${_FILE_} )
VERSION=4.1.0
MY_LIB=/Library/Frameworks
A_LIB=MyLibA
B_LIB=MyLibB
contains( TEMPLATE, lib ) {
CONFIG += lib_bundle explicitlib
DESTDIR = $${MY_LIB}
FRAMEWORK_HEADERS.version = Versions
FRAMEWORK_HEADERS.files = $${HEADERS}
FRAMEWORK_HEADERS.path = Headers
QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS
QMAKE_FRAMEWORK_BUNDLE_NAME = $${TGT}
QMAKE_FRAMEWORK_VERSION = $${VERSION}
}
contains( TEMPLATE, app ) {
DESTDIR = /Applications
TARGET=$${TGT}
}
MY_A_LIB=$${A_LIB}
MY_A_INC=$${A_LIB}".framework/Headers"
MY_B_LIB=$${B_LIB}
MY_B_INC=$${B_LIB}".framework/Headers"
contains( CONFIG, alib ) {
INCLUDEPATH += $${MY_LIB}/$${MY_A_INC}
LIBS += -framework $${MY_A_LIB}
}
contains( CONFIG, blib ) {
INCLUDEPATH += $${MY_LIB}/$${MY_B_INC}
LIBS += -framework $${MY_B_LIB}
}
To copy to clipboard, switch view to plain text mode
Then both Lib qmake.pro files are like this:
TEMPLATE=LIB
TGT=MyLibA
#TGT=MyLibB
#CONFIG += alib
HEADERS += a.h a2.h
SOURCES += a.cpp a2.cpp
include( ../qmake.pri )
TEMPLATE=LIB
TGT=MyLibA
#TGT=MyLibB
#CONFIG += alib
HEADERS += a.h a2.h
SOURCES += a.cpp a2.cpp
include( ../qmake.pri )
To copy to clipboard, switch view to plain text mode
And MyApp has a pro file like this:
TEMPLATE=APP
TGT=MyApp
CONFIG += alib blib
HEADERS = myApp.h
SOURCES = myApp.cpp main.cpp
include( ../qmake.pri )
TEMPLATE=APP
TGT=MyApp
CONFIG += alib blib
HEADERS = myApp.h
SOURCES = myApp.cpp main.cpp
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.
#inside /Library/Frameworks
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
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
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
#inside /Applications
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
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
#inside /Library/Frameworks
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
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
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
#inside /Applications
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
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.
Bookmarks