[英]Is it possible to use C++ code in html5?
I want to make an app for which i need to include a part of my c++ code for calculation.我想制作一个应用程序,我需要在其中包含我的 C++ 代码的一部分进行计算。 For GUI i'm using HTML5.对于 GUI,我使用的是 HTML5。 So is it possible to include C++ code into HTML5 ?那么是否可以将 C++ 代码包含到 HTML5 中?
No. You can't do that.不,你不能那样做。 Try porting your C++ to JavaScript.尝试将您的 C++ 移植到 JavaScript。 You could take a look at this project that claims it can convert C++ code to JavaScript.你可以看看这个声称它可以将 C++ 代码转换为 JavaScript 的项目。 I have never tried this myself.我自己从来没有尝试过这个。
Otherwise, you could write a CGI to use your C++ program and use AJAX to "remote execute it".否则,您可以编写一个 CGI 来使用您的 C++ 程序并使用 AJAX 来“远程执行它”。
It is not easily possible to use C++ code in HTML5;在 HTML5 中使用 C++ 代码并不容易; but it depends what you really want to do.但这取决于您真正想要做什么。
You should first understand what HTTP and HTML5 really are, and where you want the C++ code to run (in the browser - on the HTTP client side, or in the server - on the HTTP server side).您应该首先了解什么是HTTP和HTML5 ,以及您希望 C++ 代码运行的位置(在浏览器中 - 在 HTTP 客户端,或在服务器中 - 在 HTTP 服务器端)。
If you want to use C++ code on the client side (in the browser), you probably want something like Google Native Client .如果您想在客户端(在浏览器中)使用 C++ 代码,您可能需要类似Google Native Client 的东西。 Not all browsers are supporting it, and your user needs to enable it.并非所有浏览器都支持它,您的用户需要启用它。 You could also consider compiling your C++ code to Javascript with Emscripten .您还可以考虑使用Emscripten将 C++ 代码编译为 Javascript。
If you want C++ code on the server side, you may want to use CGI or FastCGI techniques, or make your C++ code a specialized HTTP server by using some HTTP server library (like libonion or Wt )如果您希望在服务器端使用 C++ 代码,您可能需要使用CGI或FastCGI技术,或者通过使用某些 HTTP 服务器库(如libonion或Wt )使您的 C++ 代码成为专门的 HTTP 服务器
See also this question .另请参阅此问题。
尝试使用 Javascript 进行计算。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.