环境搭建

本文主要是针对ubuntu/mac编译环境搭建和调试环境 可以直接参考下面的dockerfile

qt wasm build
docker pull colorlength/qt-webassembly-build-env:latest docker run -v $BUILD_PWD/build_wasm:/project/build -v $SOURCE_PWD:/project/source colorlength/qt-webassembly-build-env:latest $BUILD_PWD编译目录
$BUILD_PWD源码目录qt pro所在路径
注意源码中的路径必须是/

https://github.com/QueenConch/wasm

1.运行环境

选择了虚拟机里安装了ubuntu版本和内核号如图

2. 安装emscripten

按照https://emscripten.org/docs/getting_started/index.html的方式安装最新版emscripten编译器

首先下载

# Get the emsdk repo
git clone https://github.com/emscripten-core/emsdk.git # Enter that directory
cd emsdk

然后安装em++

# Fetch the latest version of the emsdk (not needed the first time you clone)
git pull # Download and install the latest SDK tools.
./emsdk install latest # Make the "latest" SDK "active" for the current user. (writes ~/.emscripten file)
./emsdk activate latest # Activate PATH and other environment variables in the current terminal
source ./emsdk_env.sh

选择安装Python CMake Java

# Install Python
sudo apt-get install python2.7 # Install CMake (optional, only needed for tests and building Binaryen)
sudo apt-get install cmake # Install Java (optional, only needed for Closure Compiler minification)
sudo apt-get install default-jre

当然你也可以选择安装特定版本的em++这里我就选择最新版拉下面步骤跳过y

./emsdk install 1.38.45

可以指定特定版本的后台

# Get a specific version using the upstream backend.
./emsdk install latest-upstream # Get a specific version using the fastcomp backend.
./emsdk install 1.38.45-fastcomp

输入查看版本

em++ --version

能显示出emcc版本号 到此编译器安装成功

3.编译安装qt

1. 已经安装qt 5.14以上的小伙伴打开qt目录下的 MaintenanceTool进行修改增加qt的源码

新安装的小伙伴在

https://download.qt.io/official_releases/qt/5.14/5.14.1/

下载对应的版本并运行

chmod +x 程序 ./程序

填上邮箱开始安装拉

钩上4.11的qt和源码开始安装拉

安装完成后关闭。

考虑到编译器版本兼容问题,决定手动编译qt源码生产成webassembly二进制。

不想编译的可以用在线版本安装编译好的webassembly二进制

下载地址在里面可以选择编译好的webassembly版本这里我们跳过这一部直接开始编译

https://download.qt.io/official_releases/online_installers/

4.编译qt库

qt目录下新建一个目录来存放编译的进制库

比如我在qt目录下建了一个wasmbuild的目录方便存文件

cd进入qt源码目录 输入刚才建的目录开始编译确认。

~/Qt5.14.1/5.14.1/Src  
./configure -xplatform wasm-emscripten -nomake examples -prefix ../wasmbuild/qtbase

其中要选择开源版并同意协调

开始编译吧 这步比较久,喝个茶再回来

make module-qtbase module-qtdeclarative

这个时候编译报错了

查了一下资料

For @Calinou's issue, it's because emscripten 1.39.5 broke compatibility again: https://github.com/emscripten-core/emscripten/blob/incoming/ChangeLog.md#v1395-12202019

Removed timestamp field from mouse, wheel, devicemotion and deviceorientation events. The presence of a timestamp on these events was slightly arbitrary, and populating this field caused a small profileable overhead that all users might not care about. It is easy to get a timestamp of an event by calling emscripten_get_now() or emscripten_performance_now() inside the event handler function of any event.

qt更新比较慢5.14.1还不支持新版em++

我改回em++ 1.38.30

./emsdk install sdk-fastcomp-1.38.30-64bit

./emsdk activate --embedded sdk-fastcomp-1.38.30-64bit

source ./emsdk_env.sh

重新回到源码目录进行编译并安装到wasm目录下

./configure -xplatform wasm-emscripten -nomake examples -prefix ../wasmbuild/qtbase
make module-qtbase module-qtdeclarative
make install

成功!

这个时候就能用编译的qmake 的命令行 编译项目拉,配置一下qtcreator会比较方便下一步

比如

$ ~/Qt5.14.1/5.14.1/wasmbuild/qtbase/bin/qmake
$ make

到此命令行的编译环境配置完毕

下面我们配置一下qtcreator界面调试哈

5.设置调试

1.qt creator打开webassembly的插件

配置编译器

配置qt版本(qmake)

配置kit

6.运行demo

7.可参考Dockerfile


FROM trzeci/emscripten:1.38.45 AS baseBuild


ARG packages="build-essential git cmake \
python3 \
python \
ninja-build \
build-essential \
wget \
"
# Required for non-interactive timezone installation
RUN ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime
RUN apt-get update && apt-get install -q -yy $packages


RUN mkdir -p /root/dev
WORKDIR /root/dev


# RUN git clone https://github.com/emscripten-core/emsdk.git
# WORKDIR /root/dev/emsdk


# RUN ./emsdk install sdk-fastcomp-1.38.30-64bit
# RUN ./emsdk activate --embedded sdk-fastcomp-1.38.30-64bit


# ENV PATH="/root/dev/emsdk:/root/dev/emsdk/fastcomp-clang/e1.38.30_64bit:/root/dev/emsdk/node/8.9.1_64bit/bin:/root/dev/emsdk/emscripten/1.38.30:${PATH}"


FROM baseBuild AS qtbuilder
# ARG targetBranch=5.14.1
RUN mkdir -p /development
WORKDIR /development


# RUN git clone --branch=$targetBranch git://code.qt.io/qt/qt5.git
RUN wget https://download.qt.io/archive/qt/5.14/5.14.1/single/qt-everywhere-src-5.14.1.tar.xz
RUN tar -xvJf qt-everywhere-src-5.14.1.tar.xz


WORKDIR /development/qt5


RUN mkdir -p /development/qt5_build
WORKDIR /development/qt5_build


RUN /development/qt-everywhere-src-5.14.1/configure -xplatform wasm-emscripten -nomake examples -nomake tests -opensource -feature-thread --confirm-license -prefix /usr/local/Qt
RUN make module-qtbase module-qtdeclarative -j `grep -c '^processor' /proc/cpuinfo`
# RUN make -j `grep -c '^processor' /proc/cpuinfo`
RUN make install


# Construct the build image from user perspective
FROM baseBuild AS userbuild


COPY --from=qtbuilder /usr/local/Qt /usr/local/Qt
ENV PATH="/usr/local/Qt/bin:${PATH}"


WORKDIR /project/build
# CMD qmake /project/source && make -j `grep -c '^processor' /proc/cpuinfo`
CMD /usr/local/Qt/bin/qmake /project/source && make -j `grep -c '^processor' /proc/cpuinfo`

 


参考资料:

1.Qt for WebAssembly官方教程

https://doc.qt.io/qt-5/wasm.html

2. WebAssembly的限制

https://doc.qt.io/qt-5/qtwebassembly-platform-notes.html

3. Qt 下载地址主源

https://download.qt.io/

4.emscripten编译器的文档

https://emscripten.org/docs/getting_started/index.html

qt webassembly emscripten build 编译 环境搭建 JS调用C++传参的更多相关文章

  1. Emscripten编译环境搭建--将C和C++编译成JS

    Emscripten编译环境搭建--将C和C++编译成JS 需求:linux环境下用js执行c.c++文件,使用emscirpten编译器 目标:搭建好Emscripten环境 环境:Ubuntu16 ...

  2. ubuntu12.04下安卓编译环境搭建总结

    前言:      因为工作需要,经常要编译安卓下的动态库,公司有已经搭建好环境的服务器,但是第一自己想自己搭建一下了解一个整个过程,另外,公司的服务器也经常出现问 题,导致编译不了,所以就想自己搭建环 ...

  3. IoT设备程序开发及编译环境搭建初体验

    引言 Mirai事件一经曝出,立即引领了一轮研究IoT设备的热潮.目前,对Mirai的报告大多只是在对其功能实现上的介绍,却很少提及如何实现IoT设备程序开发的测试环境.本文在对Mirai的源码研究的 ...

  4. Tiny4412 开发板 编译环境搭建【转】

    本文转载自:http://blog.csdn.net/beijiwei/article/details/51055369 版权声明:本文为博主原创文章,未经博主允许不得转载. /*********** ...

  5. windows下cocos2dx3.0开发环境及Android编译环境搭建

    cocos2dx更新到了3.x版本号,自己一直没有换,如今开发组要求统一换版本号,我就把搭建好开发环境的过程记录下来. 一.Windowns下开发环境搭建 1.  所需工具         1)coc ...

  6. openwrt(一):openwrt源码下载及编译环境搭建

    声明:从网上各位大神的博客学习,整理后记录,非原创. 注:请用非root用户来下载源码 导航: 1. openwrt编译环境搭建 2. openwrt源码下载 3. feeds更新 1. openwr ...

  7. C语言编程入门之--第二章编译环境搭建

    第二章 编译环境搭建 导读:C语言程序如何工作,首先需要编译链接成可执行文件,然后就可以运行在不同的环境中,这个“环境”的意思就是比如说,电脑,手机,路由器,蓝牙音箱等等智能设备中,其中编译器启到了关 ...

  8. u-boot 移植(一)编译环境搭建

    u-boot 移植(一)编译环境搭建 soc:s3c2440 board:jz2440 uboot:u-boot-2016.11 toolchain:gcc-linaro-7.4.1-2019.02- ...

  9. JS基础之传参(值传递、对象传递)

    一.概念 我们需了解什么是按值传递(call by value),什么是按引用传递(call by reference).在计算机科学里,这个部分叫求值策略(Evaluation Strategy). ...

  10. js 不固定传参

      js 不固定传参 CreationTime--2018年7月2日15点18分 Author:Marydon /** * 声明一个函数 * @explain 传参个数不确定 */ function ...

随机推荐

  1. Python学习:画K帮

    import datetime import pandas_datareader.data as web df_stockload = web.DataReader("600797.SS&q ...

  2. js 浮点数加、减、乘、除。

    1.浮点数加法运算 function numAdd(arg1, arg2) { var r1, r2, m; try { r1 = arg1.toString().split("." ...

  3. 使用cutlass编译时,需要指定架构和sm

    对于Turing架构,nvcc需要加上选项 -gencode=arch=compute_75,code=sm_75   其他架构类似.

  4. 修改系统hosts文件访问github

    C:\Windows\System32\drivers\etc 199.232.69.194 github.global.ssl.fastly.net 140.82.114.4 github.com

  5. yaml文件读取转化为类

    首先你要有一个文件读取的方法,写一个根据传入路径 + 类来自动返回对应类的方法. /** * 根据传入的path,加载配置文件内容到对应class中 */ public static <T> ...

  6. 正确引用R及R包

    R版本不断更新,为保证数据可重复性,引用R时需标注出对应的R版本.那么如何引用呢? 打开R,键入citation(),得到对应的版本引用信息. To cite R in publications us ...

  7. Ngrinder(性能测试工具)-(一)

    一.ngrinder介绍 nGrinder 是基于Grinder开源项目,由NHN公司的开发团队进行了重新设计和完善. nGrinder 是一款非常易用,有简洁友好的用户界面 和 controller ...

  8. 2022.11.13 NOIP2022 模拟赛八

    「ROI 2017 Day 2」存储器 无聊的题. 首先 \(s\) 中每一个片段,其在 \(t\) 中对应的字符必然是相同的. 对于 \(t\) 中的每一个片段,考虑检查能否操作出这个片段,实际上只 ...

  9. 2019-2020-1 20199318《Linux内核原理与分析》第八周作业

    第7章 可执行程序工作原理 一.学习笔记 1.ELF 2.程序编译 3.连接与库 二.试验记录 1.开始先更新内核,再用test_exec.c将test.c覆盖掉 2.test.c文件中增加了exec ...

  10. shell中;与&&的区别

    &&  后一个命令执行需要依赖前一个命令执行成功 :各个命令都会依次执行,无论成功与否