Results 1 to 2 of 2

Thread: Bad relink libs on QT4 Mac OSX (install_name_tool)

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Bad relink libs on QT4 Mac OSX (install_name_tool)

    I have build a Universal apps ... now i take script from http://qtnode.net/wiki/Distributing_Mac_Qt_applications

    i set my path and install_name_tool not relink correct the new libs inside apps ...

    if i rename my local /Library/Frameworks/QtCore.framework the apps not take libs from new set install_name_tool why?? wo is mistake?

    Qt Code:
    1. #!/bin/bash
    2. #
    3. # Configuration start
    4. #
    5.  
    6. # relative path to the directory which contains the created app bundle
    7. BIN_DIR="bin"
    8. # name of the binary
    9. BINARY_NAME="edithtml"
    10. # Qt libraries you've linked against on apps remove not needed libs
    11. declare -a NEEDED_LIBS=( "QtCore" "QtGui" "QtXml" "QtSql" "QtNetwork" "QtOpenGL" "QtSvg")
    12. # additional files you'd like to get copied to the final dmg
    13. declare -a ADD_FILES=("bin/ticket.pdf" "bin/copying.txt")
    14.  
    15. #
    16. # Configuration end, nothing should be edited from here on
    17. #
    18. # on main.cpp
    19. #if defined Q_WS_MAC
    20. #QStringList path;
    21. #path.append(QApplication::applicationDirPath());
    22. #QDir dir(QApplication::applicationDirPath());
    23. #dir.cdUp();
    24. #path.append(dir.absolutePath());
    25. #dir.cd("plugins");
    26. #path.append(dir.absolutePath());
    27. #dir.cdUp();
    28. #path.append(dir.absolutePath());
    29. #QApplication::setLibraryPaths(path);
    30. #QDir::setCurrent(dir.absolutePath()); /* here down -> Frameworks */
    31. #endif
    32.  
    33.  
    34. qtbaselibpath="/Library/Frameworks"
    35. bundle_dir="$BIN_DIR/$BINARY_NAME.app"
    36. bundle_bin="$bundle_dir/Contents/MacOS/$BINARY_NAME"
    37. framework_dir="$bundle_dir/Contents/Frameworks"
    38. plugin_dir="$bundle_dir/Contents/plugins"
    39. locale_dir="$bundle_dir/Contents/locale"
    40.  
    41.  
    42.  
    43.  
    44. if [ ! -d "$bundle_dir" ]; then
    45. echo "Application bundle not found in bin... exiting."
    46. exit 1
    47. fi
    48.  
    49. echo "Creating Frameworks directory in application bundle..."
    50. mkdir -p "$framework_dir"
    51. mkdir -p $plugin_dir
    52. mkdir -p $locale_dir
    53.  
    54. libcount=${#NEEDED_LIBS[@]}
    55. for (( i = 0 ; i < libcount ; i++ ))
    56. do
    57. lib=${NEEDED_LIBS[$i]}
    58. echo "Processing $lib..."
    59.  
    60. if [ ! -d "$qtbaselibpath/$lib.framework" ]; then
    61. echo "Couldn't find $lib.framework in $qtbaselibpath."
    62. exit 1
    63. fi
    64.  
    65.  
    66. rm -rf "$framework_dir/$lib.framework"
    67. cp -fR "$qtbaselibpath/$lib.framework" "$framework_dir"
    68. echo "...$lib copied."
    69.  
    70. install_name_tool \
    71. -id "@executable_path/../Frameworks/$lib.framework/Versions/4/$lib" \
    72. "$framework_dir/$lib.framework/Versions/4/$lib"
    73.  
    74. # other Qt libs depend at least on QtCore
    75. if [ "$lib" != "QtCore" ]; then
    76. install_name_tool -change "$qtbaselibpath/QtCore.framework/Versions/4/QtCore" \
    77. "@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore" \
    78. "$framework_dir/$lib.framework/Versions/Current/$lib"
    79. fi
    80.  
    81. install_name_tool -change "$qtbaselibpath/$lib.framework/Versions/4/$lib" \
    82. "@executable_path/../Frameworks/$lib.framework/Versions/4/$lib" \
    83. "$bundle_bin"
    84.  
    85. echo "...$lib done."
    86. done
    87.  
    88.  
    89. echo "Removing any debug libraries and headers..."
    90. find "$framework_dir" | egrep "debug|Headers" | xargs rm -rf
    91.  
    92. echo "Preparing image directory..."
    93. tempdir="/tmp/`basename $0`.$$"
    94. mkdir $tempdir
    95. cp -R $bundle_dir $tempdir
    96. echo "...Bundle copied"
    97. fcount=${#ADD_FILES[@]}
    98. for (( i = 0 ; i < fcount ; i++ )) do
    99. file=${ADD_FILES[$i]}
    100. if [ ! -f "$file" ]; then
    101. echo "WARNING: $file not found!"
    102. else
    103. cp "$file" $tempdir
    104. echo "...$file copied"
    105. fi
    106. done
    107. echo "Creating disk image..."
    108. rm -f "$BIN_DIR/$BINARY_NAME.dmg"
    109. # format UDBZ: bzip2 compressed (10.4+), UDZ0: zlib compressed (default)
    110. hdiutil create -srcfolder $tempdir -format UDBZ -volname "$BINARY_NAME" "$BIN_DIR/$BINARY_NAME.dmg"
    111. rm -rf $tempdir
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Bad relink libs on QT4 Mac OSX (install_name_tool)

    Ok .. i solved ...
    To all mac user OSX
    i chance && rebuild qt-mac-opensource-src-4.3.0beta.tar.gz
    ftp://ftp.trolltech.com/qt/source/qt...3.0beta.tar.gz and now running exelent ...

    note to distritibuiting apps universal on mac not use any .dmg package from trolltech this is only to test and self use.... to build fast apps from source code ... on self OSX ... qt4 install on 2 Min.

    use shortly dir name! prefix and set the envoirment $PATH && $QTDIR on ~/.profile

    curl -O ftp://ftp.trolltech.com/qt/source/qt...3.0beta.tar.gz

    &&

    Qt Code:
    1. ./configure -prefix /opt/qt -qt-zlib -qt-sql-sqlite -qt-gif -qt-libpng -qt-libjpeg -universal -sdk /Developer/SDKs/MacOSX10.4u.sdk
    To copy to clipboard, switch view to plain text mode 

    Your option ...

    build code on mini mac 256 MB Ram 5-6 H.

    make package to distritibuiting apps chance your path && app name... && run ...


    Qt Code:
    1. #!/bin/bash
    2. #
    3. # Configuration start
    4. #
    5.  
    6. # relative path to the directory which contains the created app bundle
    7. BIN_DIR="bin"
    8. # name of the binary
    9. BINARY_NAME="edithtml"
    10. # Qt libraries you've linked against on apps remove not needed libs
    11. declare -a NEEDED_LIBS=( "QtCore" "QtGui" "QtXml" "QtSql" "QtNetwork" "QtOpenGL" "QtSvg")
    12. # additional files you'd like to get copied to the final dmg
    13. declare -a ADD_FILES=("bin/ticket.pdf" "bin/copying.txt")
    14.  
    15. #
    16. # Configuration end, nothing should be edited from here on
    17. #
    18. # on main.cpp
    19. #if defined Q_WS_MAC
    20. #QStringList path;
    21. #path.append(QApplication::applicationDirPath());
    22. #QDir dir(QApplication::applicationDirPath());
    23. #dir.cdUp();
    24. #path.append(dir.absolutePath());
    25. #dir.cd("plugins");
    26. #path.append(dir.absolutePath());
    27. #dir.cdUp();
    28. #path.append(dir.absolutePath());
    29. #QApplication::setLibraryPaths(path);
    30. #QDir::setCurrent(dir.absolutePath()); /* here down -> Frameworks */
    31. #endif
    32.  
    33. bundle_dir="$BIN_DIR/$BINARY_NAME.app"
    34. bundle_bin="$bundle_dir/Contents/MacOS/$BINARY_NAME"
    35. framework_dir="$bundle_dir/Contents/Frameworks"
    36.  
    37. #### make plugin && locale dir after the before the 2° run oft this script copy image sql
    38. #### plugin inside... or at end right click apps and info apps select locale to activate...
    39.  
    40. plugin_dir="$bundle_dir/Contents/plugins"
    41. locale_dir="$bundle_dir/Contents/locale"
    42.  
    43. if [ -z $QTDIR ]; then
    44. echo "\$QTDIR environment variable not found... exiting."
    45. exit 1
    46. fi
    47.  
    48. # canonicalize QtDir, unfortunately this bash has no realpath() implementation
    49. # so we need to use perl for this
    50. QTDIR=`perl -e "use Cwd 'realpath'; print realpath('$QTDIR');"`
    51.  
    52. if [ ! -d "$bundle_dir" ]; then
    53. echo "Application bundle not found in bin... exiting."
    54. exit 1
    55. fi
    56.  
    57. echo "Creating Frameworks directory in application bundle..."
    58. mkdir -p "$framework_dir"
    59. mkdir -p $plugin_dir
    60. mkdir -p $locale_dir
    61.  
    62. libcount=${#NEEDED_LIBS[@]}
    63. for (( i = 0 ; i < libcount ; i++ ))
    64. do
    65. lib=${NEEDED_LIBS[$i]}
    66. echo "Processing $lib..."
    67.  
    68. if [ ! -d "$QTDIR/lib/$lib.framework" ]; then
    69. echo "Couldn't find $lib.framework in $QTDIR."
    70. exit 1
    71. fi
    72.  
    73. rm -rf "$framework_dir/$lib.framework"
    74. cp -fR "$QTDIR/lib/$lib.framework" "$framework_dir"
    75. echo "...$lib copied."
    76.  
    77. install_name_tool \
    78. -id "@executable_path/../Frameworks/$lib.framework/Versions/4/$lib" \
    79. "$framework_dir/$lib.framework/Versions/4/$lib"
    80.  
    81. # other Qt libs depend at least on QtCore
    82. if [ "$lib" != "QtCore" ]; then
    83. install_name_tool -change "$QTDIR/lib/QtCore.framework/Versions/4/QtCore" \
    84. "@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore" \
    85. "$framework_dir/$lib.framework/Versions/Current/$lib"
    86. fi
    87.  
    88. install_name_tool -change "$QTDIR/lib/$lib.framework/Versions/4/$lib" \
    89. "@executable_path/../Frameworks/$lib.framework/Versions/4/$lib" \
    90. "$bundle_bin"
    91.  
    92. echo "...$lib done."
    93. done
    94.  
    95.  
    96. echo "Removing any debug libraries and headers..."
    97. find "$framework_dir" | egrep "debug|Headers" | xargs rm -rf
    98.  
    99. echo "Preparing image directory..."
    100. tempdir="/tmp/`basename $0`.$$"
    101. mkdir $tempdir
    102. cp -R $bundle_dir $tempdir
    103. echo "...Bundle copied"
    104. fcount=${#ADD_FILES[@]}
    105. for (( i = 0 ; i < fcount ; i++ )) do
    106. file=${ADD_FILES[$i]}
    107. if [ ! -f "$file" ]; then
    108. echo "WARNING: $file not found!"
    109. else
    110. cp "$file" $tempdir
    111. echo "...$file copied"
    112. fi
    113. done
    114. echo "Creating disk image..."
    115. rm -f "$BIN_DIR/$BINARY_NAME.dmg"
    116. # format UDBZ: bzip2 compressed (10.4+), UDZ0: zlib compressed (default)
    117. hdiutil create -srcfolder $tempdir -format UDBZ -volname "$BINARY_NAME" "$BIN_DIR/$BINARY_NAME.dmg"
    118. rm -rf $tempdir
    To copy to clipboard, switch view to plain text mode 

    the result can work self whitout installed /opt/qt ....

    http://qtnode.net/wiki/Distributing_Mac_Qt_applications
    http://doc.trolltech.com/4.2/deployment-mac.html
    Last edited by patrik08; 7th April 2007 at 09:07.

Similar Threads

  1. qmake, conditioning & bundled libs
    By sebr in forum Qt Programming
    Replies: 3
    Last Post: 29th September 2006, 09:38
  2. Using qmake to build multiple apps and libs
    By marchand in forum Newbie
    Replies: 2
    Last Post: 12th June 2006, 17:33
  3. Qt libs static and dynamic
    By conexion2000 in forum Installation and Deployment
    Replies: 3
    Last Post: 24th May 2006, 09:09
  4. Burn libs
    By Elgrimm Esleborn in forum General Programming
    Replies: 2
    Last Post: 16th March 2006, 15:12
  5. use libs under qt4
    By raphaelf in forum Qt Programming
    Replies: 6
    Last Post: 27th February 2006, 17:59

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.