Issues using the platform SDK on a new installation

I had installed the SailfishSDK (EA for including QtCreator, Emulator etc. a week ago, and have been working with it without problems since.
Now I wanted to deploy my app to my phone, so in order to build an rpm package, I followed those pages:

I have set up the PlatformSDK and afterwards several tagets:

sdk-assistant create SailfishOS-
sdk-assistant create SailfishOS-

Now when I try to build the app with mb2 -t SailfishOS- build , I’ll get a crapload of errors:

+ export LD_AS_NEEDED
+ export QT_SELECT=5
+ qmake -qt=5 -makefile 'QMAKE_CFLAGS_RELEASE=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -march=armv8-a' 'QMAKE_CFLAGS_DEBUG=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -march=armv8-a' 'QMAKE_CXXFLAGS_RELEASE=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -march=armv8-a' 'QMAKE_CXXFLAGS_DEBUG=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -march=armv8-a' QMAKE_STRIP=: PREFIX=/usr LIBDIR=/usr/lib64
+ make -j16
g++ -c -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -march=armv8-a -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -isystem /usr/include/sailfishapp -isystem /usr/include/mdeclarativecache5 -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtQuick -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtQml -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtCore -I. -I/usr/share/qt5/mkspecs/linux-g++ -o myapp.o src/myapp.cpp
src/myapp.cpp: In function 'int main(int, char**)':
src/myapp.cpp:12:4: error: 'qmlRegisterType' was not declared in this scope
    qmlRegisterType<MyModel>("MyApp", 1, 0, "MyModel");
src/myapp.cpp:12:4: note: suggested alternative: 'qRegisterMetaType'
    qmlRegisterType<MyModel>("MyApp", 1, 0, "MyModel");
src/myapp.cpp:12:30: error: expected primary-expression before '>' token
    qmlRegisterType<MyModel>("MyApp", 1, 0, "MyModel");
src/myapp.cpp:12:42: warning: left operand of comma operator has no effect [-Wunused-value]
    qmlRegisterType<MyModel>("MyApp", 1, 0, "MyModel");
src/myapp.cpp:12:45: warning: right operand of comma operator has no effect [-Wunused-value]
    qmlRegisterType<MyModel>("MyApp", 1, 0, "MyModel");
src/myapp.cpp:12:48: warning: right operand of comma operator has no effect [-Wunused-value]
    qmlRegisterType<MyModel>("MyApp", 1, 0, "MyModel");
src/myapp.cpp:18:8: error: invalid use of incomplete type 'class QQuickView'
In file included from src/myapp.cpp:5:
/usr/include/sailfishapp/sailfishapp.h:38:7: note: forward declaration of 'class QQuickView'
 class QQuickView;
src/myapp.cpp:19:8: error: invalid use of incomplete type 'class QQuickView'
In file included from src/myapp.cpp:5:
/usr/include/sailfishapp/sailfishapp.h:38:7: note: forward declaration of 'class QQuickView'
 class QQuickView;
src/myapp.cpp:21:14: error: invalid use of incomplete type 'class QGuiApplication'
    return app->exec();
In file included from src/myapp.cpp:5:
/usr/include/sailfishapp/sailfishapp.h:37:7: note: forward declaration of 'class QGuiApplication'
 class QGuiApplication;
In file included from /usr/include/qt5/QtCore/qobject.h:47,
                 from /usr/include/qt5/QtCore/qvariant.h:45,
                 from /usr/include/qt5/QtCore/qabstractitemmodel.h:37,
                 from /usr/include/qt5/QtCore/QAbstractListModel:1,
                 from src/mymodel.h:4,
                 from src/myapp.cpp:7:
/usr/include/qt5/QtCore/qscopedpointer.h: In instantiation of 'static void QScopedPointerDeleter<T>::cleanup(T*) [with T = QGuiApplication]':
/usr/include/qt5/QtCore/qscopedpointer.h:101:25:   required from 'QScopedPointer<T, Cleanup>::~QScopedPointer() [with T = QGuiApplication; Cleanup = QScopedPointerDeleter<QGuiApplication>]'
src/myapp.cpp:15:76:   required from here
/usr/include/qt5/QtCore/qscopedpointer.h:51:40: error: invalid application of 'sizeof' to incomplete type 'QGuiApplication'
         typedef char IsIncompleteType[ sizeof(T) ? 1 : -1 ];
/usr/include/qt5/QtCore/qscopedpointer.h: In instantiation of 'static void QScopedPointerDeleter<T>::cleanup(T*) [with T = QQuickView]':
/usr/include/qt5/QtCore/qscopedpointer.h:101:25:   required from 'QScopedPointer<T, Cleanup>::~QScopedPointer() [with T = QQuickView; Cleanup = QScopedPointerDeleter<QQuickView>]'
src/myapp.cpp:16:61:   required from here
/usr/include/qt5/QtCore/qscopedpointer.h:51:40: error: invalid application of 'sizeof' to incomplete type 'QQuickView'
make: *** [Makefile:454: myapp.o] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.VRf2xo (%build)

RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.VRf2xo (%build)
No journal files were found.
Failed to seek to cursor: Invalid argument

The corresponding source looks like this:

#include <QtQuick>

#include <sailfishapp.h>

#include "mymodel.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
   qmlRegisterType<MyModel>("MyApp", 1, 0, "MyModel");

   QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
   QScopedPointer<QQuickView> view(SailfishApp::createView());


   return app->exec();

I’m not entirely sure whats going on, but I get the feeling that there is a QT version mismatch.

How can I fix this?

I’m sorry those instructions have taken you off track. You don’t need Platform SDK for building app packages. The Sailfish SDK is all you need. Application SDK Your First App - SailfishOS Documentation is probably a better place to start reading about deploying apps to the phone.

As for your actual issue, I have a feeling it’s in your .pro file. When I tried compiling your source, it compiled just fine, after I had created a class called “MyModel”. Could you share your .pro file as well?

Ah I see. That page seems to be quite well hidden; it cannot be accessed from the main menu as it seems.
I have started by copying one of the shipped examples. I found targets for armv7hl and aarch64, and corresponding switches to build RPMs in the Sailfish IDE (QtCreator), however none of those would actually work, so I searched the docs for info on how to build RPMs.
Seems like I got onto the wrong branch, since I want to do app development rather than platform development :slight_smile:

I’ll check the instructions on the above page later and see how it goes.

One thing about RPMs: Does the page above assume that building RPMs via SF IDE should just work after it has been set up ad instructed? Or would there be additional setup necessary?
I don’t exactly remember the issues when trying to build RPMs, but I think the IDE was complaning about missing targets (I’m at the office right now and can’t access my PC).

The page does give you all the necessary instructions. Some parts are a bit outdated though, e.g. there is no such thing as “Mer Build Machine” anymore. Building RPMs does not quite “just work”, but it’s not that far off: You either have to select “Build RPM Package for Manual Deployment” in the kit selector, or configure a hardware device to deploy to, as instructed on the page.

Yeah, thats what I did, and what didn’t work.

Ok, when you get back, please tell us what kind of errors you get.

Will do, thanks for the support :slight_smile:

Okay so I have checked again, and set up my 10 ii device as instructed on the above page. I was able to deploy to it.

I then also found the correct button for just creating RPMs without deploying to a device, which also worked. In the past I had missed the “Build RPM package for manual deployment”, for whatever reason.

All in all everything worked, and also it seems to be extremely easy to used.

So sorry for the wrong alert :slight_smile:

1 Like

Actually, one thing just broke. After I deployed stuff to the 10 ii, I switched back to i486 to deploy to the emulator. I now get this in the compile output window:

09:46:54: Running steps for project photos...
09:46:54: Start Build Engine: The "Sailfish OS Build Engine" virtual machine is already running. Nothing to do.
09:46:54: Configuration unchanged, skipping qmake step.
09:46:54: Starting: "/home/s710/.config/SailfishSDK/libsfdk/build-target-tools/Sailfish OS Build Engine/SailfishOS-" 
+ /home/s710/SailfishOS/bin/sfdk make
sfdk: [I] Options from environment: -c target=SailfishOS-
Fatal: Multiple spec files found - please select one.
09:46:54: The process "/home/s710/.config/SailfishSDK/libsfdk/build-target-tools/Sailfish OS Build Engine/SailfishOS-" exited with code 1.
Error while building/deploying project photos (kit: SailfishOS- (in Sailfish OS Build Engine))
When executing step "Make"
09:46:54: Elapsed time: 00:00.

What is wrong here?

It looks like you have multiple spec files in your rpm directory. You should only have one.

Didn’t have any, all the time. Is this needed for deploying to the emulator? Pretty sure it worked so far without any spec file.

[edit] Nevermind, it was caused by some file renaming of mine.

Upgraded the SDK and (like previous updates) it doesn’t work.

Unable to connect to the docker build engine. I removed and reinstalled Docker (as I had to do that last time).

If I go into options->SailfishOS → Build Engine → Start Virtual Machine
I get: No virtual machine with the name “sailfish-os-build-engine”

If I press options->SailfishOS → Build Engine ->Add…
then there is nothing in the Available Virtual Machines.

Any clues where it is?

@crun Your question deserves a separate topic - please resubmit.