Skip to content

Instantly share code, notes, and snippets.

@theshadowx
Last active September 24, 2021 17:35
Show Gist options
  • Save theshadowx/438297ac465874a5e226 to your computer and use it in GitHub Desktop.
Save theshadowx/438297ac465874a5e226 to your computer and use it in GitHub Desktop.
Qt/Qml With Chrome Native Client (NaCl)
#!/bin/bash
set -e
# Install NaCl
wget http://storage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/nacl_sdk.zip
unzip nacl_sdk.zip
rm nacl_sdk.zip
nacl_sdk/naclsdk list
# get the latest stable bender
nacl_sdk/naclsdk install pepper_47
NACL_SDK_ROOT=$(pwd)/$(find ./nacl_sdk -maxdepth 1 -type d -name "pepper*")
echo "export NACL_SDK_ROOT=$NACL_SDK_ROOT">> ~/.bashrc
source ~/.bashrc
# Checkout Qt 5.6.0
git clone git://code.qt.io/qt/qt5.git Qt5.6
cd Qt5.6
git checkout 5.6
perl init-repository
git checkout 5.6
cd ..
cd Qt5.6/qtbase
git checkout wip/nacl
cd ../qtdeclarative
git checkout wip/nacl
cd ../qtxmlpatterns
git apply ../../qtxmlpatterns.patch
cd ../..
mkdir QtNaCl_56
cd QtNaCl_56
../Qt5.6/qtbase/nacl-configure linux_x86_newlib release 64
make module-qtbase -j6
make module-qtdeclarative -j6
make module-qtquickcontrols -j6
#running the example
# cd ../Qt5.4.2/qtdeclarative/examples/nacl
# mkdir build
# cd build
# ../../../../../QtNacl_5.4/qtbase/bin/qmake ..
# make
# ../../../../../QtNacl_5.4/qtbase/bin/nacldeployqt nacl.nexe --run
diff --git a/tools/tools.pro b/tools/tools.pro
index 92bbaca..0040747 100644
--- a/tools/tools.pro
+++ b/tools/tools.pro
@@ -1,9 +1,11 @@
TEMPLATE = subdirs
load(qfeatures)
-!android|android_app {
- SUBDIRS += xmlpatterns
- !contains(QT_DISABLED_FEATURES, xmlschema) {
- SUBDIRS += xmlpatternsvalidator
+!nacl {
+ !android|android_app {
+ SUBDIRS += xmlpatterns
+ !contains(QT_DISABLED_FEATURES, xmlschema) {
+ SUBDIRS += xmlpatternsvalidator
+ }
}
}
diff --git a/tools/xmlpatterns/xmlpatterns.pro b/tools/xmlpatterns/xmlpatterns.pro
index 0f1ee4f..1172883 100644
--- a/tools/xmlpatterns/xmlpatterns.pro
+++ b/tools/xmlpatterns/xmlpatterns.pro
@@ -14,4 +14,4 @@ HEADERS = main.h \
load(qt_tool)
# with c++11 / __STRICT_ANSI__ mingw.org stdio.h doesn't declare e.g. _fileno
-win32-g++*: QMAKE_CXXFLAGS_CXX11 = -std=gnu++0x
\ No newline at end of file
+win32-g++*: QMAKE_CXXFLAGS_CXX11 = -std=gnu++0x
diff --git a/tools/xmlpatternsvalidator/xmlpatternsvalidator.pro b/tools/xmlpatternsvalidator/xmlpatternsvalidator.pro
index af9469f..21b1b18 100644
--- a/tools/xmlpatternsvalidator/xmlpatternsvalidator.pro
+++ b/tools/xmlpatternsvalidator/xmlpatternsvalidator.pro
@@ -1,6 +1,8 @@
-QT = core xmlpatterns
+!nacl {
+ QT = core xmlpatterns
-SOURCES = main.cpp
-HEADERS = main.h
+ SOURCES = main.cpp
+ HEADERS = main.h
-load(qt_tool)
+ load(qt_tool)
+}
@kom1che
Copy link

kom1che commented May 27, 2017

Hi, thank you for clarification of the main function. I read the your previous description:

@bgrasic here is how the main.cpp should look like
#include
#include
#include "analogclock.h"
AnalogClock *clockA = 0;
// App-provided init and exit functions:
void app_init(int argc, char **argv)
{
clockA = new AnalogClock;
clockA->show();
}
void app_exit()
{
delete clockA;
}
// Register functions with Qt. The type of register function
// selects the QApplicaiton type.
Q_GUI_MAIN(app_init, app_exit);

and inserted some changes in mine project in such way

#include "service.h"
//#include <QApplication>
//#include <QObject>
#include <QtCore>
#include <QtGui>
Service *w = 0;
void app_init(int argc, char **argv)
//int app_init(int argc, char *argv[])
{
    //QApplication a(argc, argv);
    //Service w;
    w = new Service;
    //w.show();
    w->show();
    //return a.exec();
}
void app_exit()
{
    delete w;
}
Q_GUI_MAIN(app_init, app_exit);

Then, finaly project has been compiled. Here is the content of buid folder:

image

After I used run command like this:

sudo docker run --rm -it -p 8000:8000 -v /home/komche/RD_stage:/home/komche/RD_stage theshadowx/qt_nacl:pepper47_qt56 bash -c "cd /home/komche/RD_stage/build && /opt/QtNaCl_56/qtbase/bin/nacldeployqt RD-Artem.nexe --run"

Using Chrome (version 56.0.2924.87 (64-bit)) I linked to http://172.17.0.1:8000/, but unfortunately I saw only white screen with frame and the name of the project((

@kom1che
Copy link

kom1che commented May 27, 2017

image

@theshadowx
Copy link
Author

So do I, and also was reported by some people here. I couldn't debug it as the debug option works just for Mac OS.

I think it's better to contact the person maintaining nacl-wip branch in Qt --> https://github.com/msorvig

@kom1che
Copy link

kom1che commented May 28, 2017

Thank you very much for your support. I appreciate that.
Ok, I will try to contact with him, but Have you already contacted with him?

@theshadowx
Copy link
Author

theshadowx commented May 28, 2017

Yes, but not for this issue.
https://github.com/msorvig/qt5-qtbase-nacl/issues
The nacl-wip branch in Qt hasn't been updated since last year.

@kom1che
Copy link

kom1che commented Jun 4, 2017

Hi Ali!

Did you read this article on official Google web-site:

https://developer.chrome.com/native-client/migration

@theshadowx
Copy link
Author

@kom1che thanks for this info.
hope Qt guys will make Qt able to work with WebAssembly.

@kom1che
Copy link

kom1che commented Jun 10, 2017

@theshadowx
Copy link
Author

Thanks, that's great !!!

@theshadowx
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment