将 C++ 代码(本机客户端)移植到浏览器(Web 应用程序) [英] Porting c++ code (native client) to browser (Web app)

查看:30
本文介绍了将 C++ 代码(本机客户端)移植到浏览器(Web 应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Qt-creator SDK 编写的 c++ 模块.我想将此代码移植到任何网页上运行,而不会影响最终用户的源代码.用户应该能够在任何浏览器(Chrome、Firefox、Safari、Explorer)上看到这个模块的输出,而无需安装任何额外的浏览器插件.有哪些更好的选择可以实现这一目标.我用谷歌搜索并发现很少这样的选择:

I have a c++ module written using Qt-creator SDK. I want to port this code to run on any webpage without compromising the source-code to end user. User should be able to see the output of this module on any browser(Chrome, Firefox, Safari, Explorer) without having to install any additional browser plugin. What are the better options available to achieve this. I have googled and found few such options:

  1. Google Native 客户端 (NaCl) - 但它只能在 Chrome 上运行.这是 Web 应用程序的未来吗?
  2. PPAPI - 不确定它是否与 NaCl 相同
  3. NPAPI - 几乎被弃用
  4. Emscripten - 它将 c++ 转换为 js.因此用户可以看到源代码.
  5. WebAssembly

还有其他选择可以实现我正在寻找的目标吗?如果不是,我应该从上述选项中选择哪一个!?提前谢谢了.一个

Are there any other options to achievce waht I am looking for? If not which one I should pick from the above options!? Many thanks in advance. a

推荐答案

一些说明:

  1. 除 Chrome 之外的浏览器不支持 NaCl.我们(Google 的 NaCl/WebAssembly 团队)更专注于未来的 WebAssembly.
  2. PPAPI 是 NaCl 使用的 API 集.
  3. NPAPI:即将推出,无论如何都需要安装插件.
  4. Emscripten.它确实将 C++ 编译为 JS,但我不会说它会向用户显示您的源代码.通过通常的编译和优化过程,它已经发生了显着的变化,我会说它更接近机器代码而不是源代码.此外,我们正在为 emscripten 添加 WebAssembly 支持,以便您可以使用相同的源为支持它的浏览器生成 WebAssembly,并为那些不支持的浏览器生成 asm.js.
  5. WebAssembly 是未来,它将满足您的所有标准,但需要注意的是,wasm 可用的浏览器 API 和功能与 JavaScript 可用的相同.因此,例如,您将无法无限制地访问用户的文件系统.所有 4 家主要浏览器供应商都在实施 webassembly,但它应该首先出现在 Chrome 和 Firefox 中,因为这些浏览器的发布时间表与其各自的操作系统分离.

我的建议是尝试使用 emscripten 移植您的代码.你可以从今天开始并使用 asm.js,当 WebAssembly 启动时,你可以用最少的额外努力来定位它.将来会有其他支持 wasm 的工具链和语言,但今天 emscripten 确实是唯一现成的选项.

My suggestion would be to try porting your code with emscripten. You can start that today and use asm.js, and when WebAssembly launches, you can target that with minimal extra effort. In the future there will be other toolchains and languages that support wasm, but today emscripten is really the only ready-to-go option.

这篇关于将 C++ 代码(本机客户端)移植到浏览器(Web 应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆