macdeployqt does not work, imposible to create portable app on osx with go-qml

373 views
Skip to first unread message

Morris Winkler

unread,
Nov 6, 2015, 7:13:57 PM11/6/15
to go-qml

I had posted that allready on the github issue page, but i will just post it here too.

i am willing to write a blogpost on how to create a portable OSX app with go and go-qml, maybe even throw in some code to build the app on the fly, 

all i want is to get some help towards this problem here:


While this might rather be a problem with Qt5.5 i guess it can only be fixed in the go-qml itself, since it needs changes on how the c++ part is compiled, long story short.

i use macdeployqt to add qt framework to a app bundle, that way my executable is referenced to a bunch of qt libs that are relative ( portable)

i end up with something like ( so you see everything is linked relative to  @executable_path)

# otool -L myProgram
gcode2time:
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
    @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.5.0, current version 5.5.0)
    @executable_path/../Frameworks/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.5.0, current version 5.5.0)
    @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui (compatibility version 5.5.0, current version 5.5.0)
    @executable_path/../Frameworks/QtQml.framework/Versions/5/QtQml (compatibility version 5.5.0, current version 5.5.0)
    @executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.5.0, current version 5.5.0)
    @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.5.0, current version 5.5.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

when i run it i get

objc[6213]: Class NotificationReceiver is implemented in both /Users/user/tools/go/src/gcode2time/LaydropCostCalculator.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets and /usr/local/Cellar/qt5/5.5.0/lib/QtWidgets.framework/QtWidgets. One of the two will be used. Which one is undefined.

i figured that this is to the fact that QApplication::setStyle(QStyleFactory::create("Fusion")); is called before QApplication app(argc, argv); is called, well i reference that from

https://forum.qt.io/topic/50305/qt-5-3-and-5-4-mac-application-crashes-on-startup-after-using-macdeployqt-app-unable-to-load-plugin-cocoa/8

i tried to find the corresponding part in go-qml, i coudn't maybe someone has some advice on how to make sure qt main() is structured in a way that resamples this post.

Ben Campbell

unread,
Nov 16, 2015, 5:46:03 PM11/16/15
to go-qml
On Saturday, November 7, 2015 at 1:13:57 PM UTC+13, Morris Winkler wrote:
i am willing to write a blogpost on how to create a portable OSX app with go and go-qml, maybe even throw in some code to build the app on the fly, 

all i want is to get some help towards this problem here:


While this might rather be a problem with Qt5.5 i guess it can only be fixed in the go-qml itself, since it needs changes on how the c++ part is compiled, long story short.

i use macdeployqt to add qt framework to a app bundle, that way my executable is referenced to a bunch of qt libs that are relative ( portable)

i end up with something like ( so you see everything is linked relative to  @executable_path)


Not sure if this is of any use, but I've been happily doing builds of my go-qml app for Linux, Windows (32bit) and OSX without too much hassle.
I'm using Qt5.3.2 still, but plan to try upgrading to Qt5.5 soon.

For the OSX build, I build my executable then run a bundling script something like this:


# build the bundle structure
APP
="myapp.app"
mkdir $APP
mkdir $APP
/Contents
mkdir $APP
/Contents/MacOS
mkdir $APP
/Contents/Resources

# copy in all the files
cp
Info.plist $APP/Contents/
cp myapp $APP
/Contents/MacOS/
# all my qml files are in ui/
cp
-r ui $APP/Contents/Resources/

# get all the required QT stuff into the bundle
/usr/local/Cellar/qt5/5.3.2/bin/macdeployqt $APP -verbose=1 -qmldir=$APP/Contents/Resources -dmg


It's been working for me... YMMV ;-)

Reply all
Reply to author
Forward
0 new messages