PDA

View Full Version : Bad relink libs on QT4 Mac OSX (install_name_tool)



patrik08
6th April 2007, 00:04
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?




#!/bin/bash
#
# Configuration start
#

# relative path to the directory which contains the created app bundle
BIN_DIR="bin"
# name of the binary
BINARY_NAME="edithtml"
# Qt libraries you've linked against on apps remove not needed libs
declare -a NEEDED_LIBS=( "QtCore" "QtGui" "QtXml" "QtSql" "QtNetwork" "QtOpenGL" "QtSvg")
# additional files you'd like to get copied to the final dmg
declare -a ADD_FILES=("bin/ticket.pdf" "bin/copying.txt")

#
# Configuration end, nothing should be edited from here on
#
# on main.cpp
#if defined Q_WS_MAC
#QStringList path;
#path.append(QApplication::applicationDirPath());
#QDir dir(QApplication::applicationDirPath());
#dir.cdUp();
#path.append(dir.absolutePath());
#dir.cd("plugins");
#path.append(dir.absolutePath());
#dir.cdUp();
#path.append(dir.absolutePath());
#QApplication::setLibraryPaths(path);
#QDir::setCurrent(dir.absolutePath()); /* here down -> Frameworks */
#endif


qtbaselibpath="/Library/Frameworks"
bundle_dir="$BIN_DIR/$BINARY_NAME.app"
bundle_bin="$bundle_dir/Contents/MacOS/$BINARY_NAME"
framework_dir="$bundle_dir/Contents/Frameworks"
plugin_dir="$bundle_dir/Contents/plugins"
locale_dir="$bundle_dir/Contents/locale"




if [ ! -d "$bundle_dir" ]; then
echo "Application bundle not found in bin... exiting."
exit 1
fi

echo "Creating Frameworks directory in application bundle..."
mkdir -p "$framework_dir"
mkdir -p $plugin_dir
mkdir -p $locale_dir

libcount=${#NEEDED_LIBS[@]}
for (( i = 0 ; i < libcount ; i++ ))
do
lib=${NEEDED_LIBS[$i]}
echo "Processing $lib..."

if [ ! -d "$qtbaselibpath/$lib.framework" ]; then
echo "Couldn't find $lib.framework in $qtbaselibpath."
exit 1
fi


rm -rf "$framework_dir/$lib.framework"
cp -fR "$qtbaselibpath/$lib.framework" "$framework_dir"
echo "...$lib copied."

install_name_tool \
-id "@executable_path/../Frameworks/$lib.framework/Versions/4/$lib" \
"$framework_dir/$lib.framework/Versions/4/$lib"

# other Qt libs depend at least on QtCore
if [ "$lib" != "QtCore" ]; then
install_name_tool -change "$qtbaselibpath/QtCore.framework/Versions/4/QtCore" \
"@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore" \
"$framework_dir/$lib.framework/Versions/Current/$lib"
fi

install_name_tool -change "$qtbaselibpath/$lib.framework/Versions/4/$lib" \
"@executable_path/../Frameworks/$lib.framework/Versions/4/$lib" \
"$bundle_bin"

echo "...$lib done."
done


echo "Removing any debug libraries and headers..."
find "$framework_dir" | egrep "debug|Headers" | xargs rm -rf

echo "Preparing image directory..."
tempdir="/tmp/`basename $0`.$$"
mkdir $tempdir
cp -R $bundle_dir $tempdir
echo "...Bundle copied"
fcount=${#ADD_FILES[@]}
for (( i = 0 ; i < fcount ; i++ )) do
file=${ADD_FILES[$i]}
if [ ! -f "$file" ]; then
echo "WARNING: $file not found!"
else
cp "$file" $tempdir
echo "...$file copied"
fi
done
echo "Creating disk image..."
rm -f "$BIN_DIR/$BINARY_NAME.dmg"
# format UDBZ: bzip2 compressed (10.4+), UDZ0: zlib compressed (default)
hdiutil create -srcfolder $tempdir -format UDBZ -volname "$BINARY_NAME" "$BIN_DIR/$BINARY_NAME.dmg"
rm -rf $tempdir

patrik08
7th April 2007, 10:01
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-mac-opensource-src-4.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-mac-opensource-src-4.3.0beta.tar.gz

&&



./configure -prefix /opt/qt -qt-zlib -qt-sql-sqlite -qt-gif -qt-libpng -qt-libjpeg -universal -sdk /Developer/SDKs/MacOSX10.4u.sdk


Your option ...

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

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




#!/bin/bash
#
# Configuration start
#

# relative path to the directory which contains the created app bundle
BIN_DIR="bin"
# name of the binary
BINARY_NAME="edithtml"
# Qt libraries you've linked against on apps remove not needed libs
declare -a NEEDED_LIBS=( "QtCore" "QtGui" "QtXml" "QtSql" "QtNetwork" "QtOpenGL" "QtSvg")
# additional files you'd like to get copied to the final dmg
declare -a ADD_FILES=("bin/ticket.pdf" "bin/copying.txt")

#
# Configuration end, nothing should be edited from here on
#
# on main.cpp
#if defined Q_WS_MAC
#QStringList path;
#path.append(QApplication::applicationDirPath());
#QDir dir(QApplication::applicationDirPath());
#dir.cdUp();
#path.append(dir.absolutePath());
#dir.cd("plugins");
#path.append(dir.absolutePath());
#dir.cdUp();
#path.append(dir.absolutePath());
#QApplication::setLibraryPaths(path);
#QDir::setCurrent(dir.absolutePath()); /* here down -> Frameworks */
#endif

bundle_dir="$BIN_DIR/$BINARY_NAME.app"
bundle_bin="$bundle_dir/Contents/MacOS/$BINARY_NAME"
framework_dir="$bundle_dir/Contents/Frameworks"

#### make plugin && locale dir after the before the 2° run oft this script copy image sql
#### plugin inside... or at end right click apps and info apps select locale to activate...

plugin_dir="$bundle_dir/Contents/plugins"
locale_dir="$bundle_dir/Contents/locale"

if [ -z $QTDIR ]; then
echo "\$QTDIR environment variable not found... exiting."
exit 1
fi

# canonicalize QtDir, unfortunately this bash has no realpath() implementation
# so we need to use perl for this
QTDIR=`perl -e "use Cwd 'realpath'; print realpath('$QTDIR');"`

if [ ! -d "$bundle_dir" ]; then
echo "Application bundle not found in bin... exiting."
exit 1
fi

echo "Creating Frameworks directory in application bundle..."
mkdir -p "$framework_dir"
mkdir -p $plugin_dir
mkdir -p $locale_dir

libcount=${#NEEDED_LIBS[@]}
for (( i = 0 ; i < libcount ; i++ ))
do
lib=${NEEDED_LIBS[$i]}
echo "Processing $lib..."

if [ ! -d "$QTDIR/lib/$lib.framework" ]; then
echo "Couldn't find $lib.framework in $QTDIR."
exit 1
fi

rm -rf "$framework_dir/$lib.framework"
cp -fR "$QTDIR/lib/$lib.framework" "$framework_dir"
echo "...$lib copied."

install_name_tool \
-id "@executable_path/../Frameworks/$lib.framework/Versions/4/$lib" \
"$framework_dir/$lib.framework/Versions/4/$lib"

# other Qt libs depend at least on QtCore
if [ "$lib" != "QtCore" ]; then
install_name_tool -change "$QTDIR/lib/QtCore.framework/Versions/4/QtCore" \
"@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore" \
"$framework_dir/$lib.framework/Versions/Current/$lib"
fi

install_name_tool -change "$QTDIR/lib/$lib.framework/Versions/4/$lib" \
"@executable_path/../Frameworks/$lib.framework/Versions/4/$lib" \
"$bundle_bin"

echo "...$lib done."
done


echo "Removing any debug libraries and headers..."
find "$framework_dir" | egrep "debug|Headers" | xargs rm -rf

echo "Preparing image directory..."
tempdir="/tmp/`basename $0`.$$"
mkdir $tempdir
cp -R $bundle_dir $tempdir
echo "...Bundle copied"
fcount=${#ADD_FILES[@]}
for (( i = 0 ; i < fcount ; i++ )) do
file=${ADD_FILES[$i]}
if [ ! -f "$file" ]; then
echo "WARNING: $file not found!"
else
cp "$file" $tempdir
echo "...$file copied"
fi
done
echo "Creating disk image..."
rm -f "$BIN_DIR/$BINARY_NAME.dmg"
# format UDBZ: bzip2 compressed (10.4+), UDZ0: zlib compressed (default)
hdiutil create -srcfolder $tempdir -format UDBZ -volname "$BINARY_NAME" "$BIN_DIR/$BINARY_NAME.dmg"
rm -rf $tempdir




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