How to install Bacon2D on Qt 5.7 (MacOS 10.11.5)
aliasbody opened this issue · 17 comments
Hello,
I've been trying to install Bacon2D on Qt5.7 on my MacOS 10.11.5 machine, but it simply doesn't work.
I followed the README explanation, no error at all at the end. My QtCreator installation is on the /Users//Applications/QtCreator folder. So I defined that folder. I ended with two folders:
/Users/<myUser>/Applications/QtCreator/Examples/Qt-5.7/bacon2d
and
/Users/<myUser>//Applications/QtCreator/imports/Bacon2D
Then I start Qt and create a QtQuick2 project to see that the import Bacon2D doesn't return anything. When I try to run the example from the QtCreator folder directly on the terminal the message is the same:
qrc:/main.qml:3 module "Bacon2D" is not installed
What am I doing wrong?
This is what I've done so far:
git clone https://github.com/Bacon2D/Bacon2D.git
cd Bacon2D
git submodule update --init
mkdir build && cd build
$HOME/Applications/QtCreator/5.7/clang_64/bin/qmake QTPATH=$HOME/Applications/QtCreator/5.7/ ..
make
make install
Then I create a new projet and type:
import Bacon2D 1.0
The final result is always:
qrc:/main.qml:3 module "Bacon2D" is not installed
The make
and make install
command don't seem to give any error.
What am I doing wrong?
For some reason, Bacon2D can't run in Debug mode. Have you tried running it in Release mode?
I'll try it, but I still have a question, should I install it on:
- QtCreator/
- QtCreator/5.7/
- or
- QtCreator/5.7/clang_64/
?
Running in Release mode I have the exact same problem.
I think that I've found something,
Once I moved the Bacon2D folder from imports
to qml
the bacon2D module started working (well the skeleton doesn't work, but I don't have the message saying that it isn't installed).
Is it possible that there is a bug on the installer script?
The skeleton example:
import QtQuick 2.2
import Bacon2D 1.0
Game {
id: game
width: 400
height: 250
currentScene: scene
Settings {
id: settings
property int highScore: 0
property bool noSound: false
}
Scene {
id: scene
physics: true
width: parent.width
height: parent.height
Entity {
width: parent.width
height: parent.height
updateInterval: 50
behavior: ScriptBehavior {
script: {
var newPos = entity.x + 5
entity.x = newPos > parent.width ? 0 : newPos
console.log("update: x -> ", entity.x)
}
}
Rectangle {
width: 50
height: 50
color: "red"
}
}
}
}
Gives me this error qrc:/main.qml:28: ReferenceError: entity is not defined
Even a simple example:
import QtQuick 2.2
import Bacon2D 1.0
Game {
id: game
width: 800
height: 600
Scene {
id: scene
width: 300
height: 300
}
}
Fails with the following error:
16:14:16: Running steps for project BaconExample...
16:14:16: Configuration unchanged, skipping qmake step.
16:14:16: Starting: "/usr/bin/make"
make: Nothing to be done for `first'.
16:14:16: The process "/usr/bin/make" exited normally.
16:14:16: Elapsed time: 00:00.
The skeleton example doesn't work because "entity" is not defined. Add "id: entity" under the Entity object.
The second example you posted doesn't return any error at all. It seems to have compiled with no issue.
If no window is displayed, try encapsulating the Game object in a Window object. Add "import QtQuick.Window 2.2" to your list of imports.
- Indeed
- It returns an error and doesn't show anything (as soon as it open, it closes immediately with a Error Message), I will post a part of at the end of this message
- Is that something normal?
Here is a part of the bug report:
Process: untitled [671]
Path: /Users/USER/*/untitled.app/Contents/MacOS/untitled
Identifier: com.libretrend.untitled
Version: 0
Code Type: X86-64 (Native)
Parent Process: Qt Creator [339]
Responsible: untitled [671]
User ID: 501
Date/Time: 2016-06-26 00:44:13.584 +0100
OS Version: Mac OS X 10.11.5 (15F34)
Report Version: 11
Anonymous UUID: 33D629B6-2734-BF1A-9063-014105933B70
Time Awake Since Boot: 230 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000020
Exception Note: EXC_CORPSE_NOTIFY
VM Regions Near 0x20:
-->
__TEXT 00000001023dc000-00000001023e0000 [ 16K] r-x/rwx SM=COW /Users/USER/*/untitled.app/Contents/MacOS/untitled
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libbacon2dplugin.dylib 0x000000010a49244c Scene::setRunning(bool const&) + 12
1 libbacon2dplugin.dylib 0x000000010a493def Game::onApplicationStateChanged(Qt::ApplicationState) + 127
2 org.qt-project.QtCore 0x000000010303a923 QMetaObject::activate(QObject*, int, int, void**) + 883
3 org.qt-project.QtGui 0x000000010347e908 QGuiApplicationPrivate::setApplicationState(Qt::ApplicationState, bool) + 232
4 org.qt-project.QtGui 0x000000010346506b QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 155
5 libqcocoa.dylib 0x0000000106739631 QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void*) + 33
6 com.apple.CoreFoundation 0x00007fff93cc2881 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
7 com.apple.CoreFoundation 0x00007fff93ca1fbc __CFRunLoopDoSources0 + 556
8 com.apple.CoreFoundation 0x00007fff93ca14df __CFRunLoopRun + 927
9 com.apple.CoreFoundation 0x00007fff93ca0ed8 CFRunLoopRunSpecific + 296
10 com.apple.HIToolbox 0x00007fff87018935 RunCurrentEventLoopInMode + 235
11 com.apple.HIToolbox 0x00007fff87018677 ReceiveNextEventCommon + 184
12 com.apple.HIToolbox 0x00007fff870185af _BlockUntilNextEventMatchingListInModeWithFilter + 71
13 com.apple.AppKit 0x00007fff92dd0df6 _DPSNextEvent + 1067
14 com.apple.AppKit 0x00007fff92dd0226 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
15 com.apple.AppKit 0x00007fff9303fa82 -[NSApplication _doModalLoop:peek:] + 653
16 com.apple.AppKit 0x00007fff932206fb __35-[NSApplication runModalForWindow:]_block_invoke + 126
17 com.apple.AppKit 0x00007fff9303d375 -[NSApplication runModalForWindow:] + 156
18 com.apple.AppKit 0x00007fff932132c7 __19-[NSAlert runModal]_block_invoke + 158
19 com.apple.AppKit 0x00007fff930bbc1c -[NSAlert runModal] + 139
20 com.apple.AppKit 0x00007fff930eed5e __55-[NSPersistentUIRestorer promptToIgnorePersistentState]_block_invoke + 1043
21 com.apple.AppKit 0x00007fff930ee90e -[NSApplication _suppressFinishLaunchingFromEventHandlersWhilePerformingBlock:] + 28
22 com.apple.AppKit 0x00007fff930ee8b1 -[NSPersistentUIRestorer promptToIgnorePersistentState] + 247
23 com.apple.AppKit 0x00007fff92dd5f71 -[NSApplication _reopenWindowsAsNecessaryIncludingRestorableState:completionHandler:] + 196
24 com.apple.AppKit 0x00007fff92dd5d8c -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 544
25 com.apple.AppKit 0x00007fff92dd5843 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 250
26 com.apple.Foundation 0x00007fff82efc72d -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 290
27 com.apple.Foundation 0x00007fff82efc5a7 _NSAppleEventManagerGenericHandler + 102
28 com.apple.AE 0x00007fff8a13f261 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) + 531
29 com.apple.AE 0x00007fff8a13efe8 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 31
30 com.apple.AE 0x00007fff8a13ef04 aeProcessAppleEvent + 288
31 com.apple.HIToolbox 0x00007fff87028af9 AEProcessAppleEvent + 55
32 com.apple.AppKit 0x00007fff92dd1290 _DPSNextEvent + 2245
33 com.apple.AppKit 0x00007fff92dd0226 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
34 com.apple.AppKit 0x00007fff92dc4d80 -[NSApplication run] + 682
35 libqcocoa.dylib 0x000000010673853f QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2191
36 org.qt-project.QtCore 0x0000000103005eb1 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 401
37 org.qt-project.QtCore 0x000000010300a115 QCoreApplication::exec() + 341
38 com.libretrend.untitled 0x00000001023dfa64 main + 148
39 libdyld.dylib 0x00007fff81d835ad start + 1
Thread 1:
0 libsystem_kernel.dylib 0x00007fff972195e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff94f29578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff94f27341 start_wqthread + 13
Thread 2:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff97219efa kevent_qos + 10
1 libdispatch.dylib 0x00007fff8fece165 _dispatch_mgr_invoke + 216
2 libdispatch.dylib 0x00007fff8fecddcd _dispatch_mgr_thread + 52
Thread 3:
0 libsystem_kernel.dylib 0x00007fff972195e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff94f29578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff94f27341 start_wqthread + 13
Thread 4:
0 libsystem_kernel.dylib 0x00007fff972195e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff94f29578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff94f27341 start_wqthread + 13
Thread 5:
0 libsystem_kernel.dylib 0x00007fff972195e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff94f29578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff94f27341 start_wqthread + 13
Thread 6:: Dispatch queue: NSCGSDisableUpdates
0 libsystem_kernel.dylib 0x00007fff97212f72 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff972123b3 mach_msg + 55
2 com.apple.CoreGraphics 0x00007fff8a8683ee _CGSReenableUpdateForConnection + 92
3 com.apple.CoreGraphics 0x00007fff8a8680c1 CGSReenableUpdateToken + 469
4 libdispatch.dylib 0x00007fff8fed393d _dispatch_call_block_and_release + 12
5 libdispatch.dylib 0x00007fff8fec840b _dispatch_client_callout + 8
6 libdispatch.dylib 0x00007fff8fecd03b _dispatch_queue_drain + 754
7 libdispatch.dylib 0x00007fff8fed3707 _dispatch_queue_invoke + 549
8 libdispatch.dylib 0x00007fff8fec840b _dispatch_client_callout + 8
9 libdispatch.dylib 0x00007fff8fecc29b _dispatch_root_queue_drain + 1890
10 libdispatch.dylib 0x00007fff8fecbb00 _dispatch_worker_thread3 + 91
11 libsystem_pthread.dylib 0x00007fff94f294de _pthread_wqthread + 1129
12 libsystem_pthread.dylib 0x00007fff94f27341 start_wqthread + 13
Thread 7:
0 libsystem_kernel.dylib 0x00007fff972195e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff94f29578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff94f27341 start_wqthread + 13
Thread 8:
0 libsystem_kernel.dylib 0x00007fff972195e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff94f29578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff94f27341 start_wqthread + 13
Thread 9:
0 libsystem_kernel.dylib 0x00007fff972195e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff94f29578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff94f27341 start_wqthread + 13
Thread 10:: QQmlThread
0 libsystem_kernel.dylib 0x00007fff9721a2a2 poll + 10
1 org.qt-project.QtCore 0x000000010305acb0 qt_safe_poll(pollfd*, unsigned int, timespec const*) + 544
2 org.qt-project.QtCore 0x000000010305c496 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 806
3 org.qt-project.QtCore 0x0000000103005eb1 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 401
4 org.qt-project.QtCore 0x0000000102e4a1ae QThread::exec() + 110
5 org.qt-project.QtQml 0x0000000102a7e7a9 QQmlThreadPrivate::run() + 57
6 org.qt-project.QtCore 0x0000000102e4db3a QThreadPrivate::start(void*) + 362
7 libsystem_pthread.dylib 0x00007fff94f2999d _pthread_body + 131
8 libsystem_pthread.dylib 0x00007fff94f2991a _pthread_start + 168
9 libsystem_pthread.dylib 0x00007fff94f27351 thread_start + 13
Thread 11:: QSGRenderThread
0 libsystem_kernel.dylib 0x00007fff97218db6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff94f2a728 _pthread_cond_wait + 767
2 org.qt-project.QtCore 0x0000000102e4f16b QWaitConditionPrivate::wait(unsigned long) + 75
3 org.qt-project.QtCore 0x0000000102e4f012 QWaitCondition::wait(QMutex*, unsigned long) + 162
4 org.qt-project.QtQuick 0x000000010248bccd QSGRenderThread::processEventsAndWaitForMore() + 397
5 org.qt-project.QtQuick 0x000000010248c190 QSGRenderThread::run() + 832
6 org.qt-project.QtCore 0x0000000102e4db3a QThreadPrivate::start(void*) + 362
7 libsystem_pthread.dylib 0x00007fff94f2999d _pthread_body + 131
8 libsystem_pthread.dylib 0x00007fff94f2991a _pthread_start + 168
9 libsystem_pthread.dylib 0x00007fff94f27351 thread_start + 13
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000001 rbx: 0x0000000000000000 rcx: 0x0000000000000000 rdx: 0x000000010a4acc50
rdi: 0x0000000000000000 rsi: 0x00007fff5d820f67 rbp: 0x00007fff5d820f50 rsp: 0x00007fff5d820f40
r8: 0x000000000000000f r9: 0x0000000000000004 r10: 0x0000000000000010 r11: 0x00007fa8d9700000
r12: 0x0000000000000007 r13: 0x0000000103365818 r14: 0x0000000000000034 r15: 0x00007fa8d9628fd0
rip: 0x000000010a49244c rfl: 0x0000000000010246 cr2: 0x0000000000000020
Logical CPU: 4
Error Code: 0x00000004
Trap Number: 14
I have never used Bacon2D on Mac before, but I figured it would be similar to Windows.
The reason why I said you should encapsulate the Game object in a Window object is because Bacon2D was created when Qt's primary QML viewer was based on the QQuickView class. That class could take Items as its root. However, for newer versions of Qt, QQmlApplicationEngine has been the preferred to QQuickView. QQmlApplicationEngine requires a Window (or any class that inherits from it) as its root.
I'm not sure if it would solve your issue, but it's worth a try.
Before anything, I want to thank you for all your time and help you've provided me until now.
So I've made some testes and here are the results:
import QtQuick 2.7
import QtQuick.Window 2.2
import Bacon2D 1.0
Window {
visible: true
width: 640
height: 480
}
Show the window.
import QtQuick 2.7
import QtQuick.Window 2.2
import Bacon2D 1.0
Window {
visible: true
width: 640
height: 480
Game {
id: game
width: 200
height: 200
}
}
Gives the same error as posted before
import QtQuick 2.7
import QtQuick.Window 2.2
import Bacon2D 1.0
Window {
visible: true
width: 640
height: 480
Scene {
}
}
Shows the window.
import QtQuick 2.7
import QtQuick.Window 2.2
import Bacon2D 1.0
Window {
visible: true
width: 640
height: 480
Game {
id: game
width: 400
height: 250
currentScene: scene
Settings {
id: settings
property int highScore: 0
property bool noSound: false
}
Scene {
id: scene
physics: true
width: parent.width
height: parent.height
Entity {
id: entity
width: parent.width
height: parent.height
updateInterval: 50
behavior: ScriptBehavior {
script: {
var newPos = entity.x + 5
entity.x = newPos > entity.parent.width ? 0 : newPos
console.log("update: x -> ", entity.x)
}
}
Rectangle {
width: 50
height: 50
color: "red"
}
}
}
}
}
Shows the window with the red square moving
I simply don't understand why some cases work and the others return such a fatal error, that doesn't seem to make any sense to me.
But anyway, what is the right folder to put the library? There is no imports folder in my Qt5.7 installation, and all the QML plugins are in the qml folder. Shouldn't we make it look for the imports folder on the installation and only use that folder if it exists otherwise use the qml folder? The same for all the others, for now it seems to be working with clang but I'll have to do the work again in order to make it Working for iOS and then for Android.
There is a lot of issues on Mac/iOS that need to be solved:
- The qml vs import problem
- qmldir for iPhone-Clang doesn't provide a classname (which should be Bacon2D)
- For some mysterious reason, it is build against armv7 instead of arm64 (for the newer iPhones)
The fatal error happens in case 2 because a Game object must have a current scene. If the current scene is null, the application would crash. I am not really sure why this happens, but to avoid it, make sure the Game object's currentScene property is never null or undefined.
In response to where to put the library, "make install" handles that for you. If you were able to run "make" and then "make install" then all files should have been placed in their proper directories.
Thank for the explanation on the first issue, when I solve all those issues I'll try to find out why this happens.
As for the library, the make install is based on the QTPATH selected early in the installation, but it goes into an imports folder which doesn't exists. All the libraries are on the qml section.
I've tried to install it following the Box2D QML library installation https://wiki.qt.io/Build_QML_Box2D_Library, which is based on the idea of compiling the library directly from QtCreator and then move it to the right folder (the same as the one done by terminal, but using QtCreator).
If I do as explaned for the Clang64 (desktop) version, it will work and then all I have to do is move the Bacon2D folder into the QML folder in order for it to work (perfect). But for the iphone I have two errors:
- Compiled against an ARM64 architecture but it builds an ARMv7 version of the library not compactible with my iPhone 5S (maybe a XCode error?)
- There is an error while ending the process, which says that qmlplugindump doesn't exist (which is the same for Android and iOS but I honestly don't understand why it doesn't exists)
As for the MakeFile, maybe I could commit a change in order for it to look for a qml folder and add the library into that folder if it exists instead of the import one (since QtCreator doesn't look for it the same way on every platform)