Porting c++ code (native client) to browser (Web app)

若如初见. 提交于 2020-01-13 20:36:49

问题


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 client (NaCl) - But it runs only on Chrome. Is this the future of web applications??
  2. PPAPI - Not sure if it is same as NaCl
  3. NPAPI - almost depricated
  4. Emscripten - It converts c++ to js. So source-code is visible to user.
  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:


Some clarification:

  1. NaCl will not be supported by browsers other than Chrome. We (Google's NaCl/WebAssembly team) are more focused on WebAssembly for the future.
  2. PPAPI is the set of APIs used by NaCl.
  3. NPAPI: on the way out, and needs a plugin installation anyway.
  4. Emscripten. It does compile C++ to JS, but I would not say that it reveals your source code to the user. It has been significantly transformed through the usual compilation and optimization process, and I would say it's closer to machine code than source code. In addition we are adding WebAssembly support to emscripten, so that with the same source you can produce WebAssembly for those browsers that support it, and asm.js for those that don't yet.
  5. WebAssembly is the future, and will meet all of your criteria, with the caveat that the browser APIs and capabilities available to wasm are the same as those available to JavaScript. So you won't be able to get unlimited access to the user's filesystem, for example. All 4 major browser vendors are implementing webassembly, but it should appear in Chrome and Firefox first, because the release schedules of those browsers are uncoupled from their respective operating systems.

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.



来源:https://stackoverflow.com/questions/41083606/porting-c-code-native-client-to-browser-web-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!