Any way to use HTML as an interface to a C/C++ program?

Bojangles picture Bojangles · Oct 3, 2010 · Viewed 31.7k times · Source

I'm developing a product that is interfaced over USB. I want to write a control app for it, but I cannot program a GUI for poo, so I came up with the idea of using a web page (local to the app's install directory) as the interface to the program.

So, the line of communication would be: User --> HTML page (not hosted - it's local) --> C++ program --> USB port

I'd like to do it this way because it's portable, at least UI wise, and I can write HTML fluently.

My question is this: would it be possible to use an HTML page to talk to the USB port through a C++ program?

If not, I'll learn GTK - it's portable enough.

PS. Would this be possible with PHP, or (eugh) Java?

EDIT: Just realised PHP is a server-side language - it wouldn't work in my situation because the page needs to be run as a program (I.E., just use the web browser and HTML as the GUI, with the actual processing done using C/C++)

Answer

CMircea picture CMircea · Oct 3, 2010

You can actually create web applications in C++ using a toolkit called Wt (similar API to Qt). There is a standalone browser as well as a module for Apache. This way you can use C++ as your programming language the same way you would C# with ASP.NET, and thus you can also use your existing C++ code. It's not really elegant though.

I'd actually recommend you learn Qt and write the whole application on top of it. It's incredibly portable and has an extensive API for just about everything - it's an application framework; GTK+ does just the UI, and in C, although the GTKmm wrapper for C++ is nice. Check it out at http://qt.nokia.com - it's available under the GNU LGPL.