Is it possible to create a C++ application that can be run trough the browser? Is there any way to link C++ application with a database (that can be used by both Mac, Linux and Windows).
-
1Do you mean run the C++ code in the browser (in which case see http://code.google.com/p/nativeclient/) or write a web service for the server running in C++? – andrewmu Feb 23 '12 at 14:35
-
1What do you mean by linking a C++ application with a database? I mean, of course, you can easily use C++ to access various databases. – Tim Feb 23 '12 at 14:35
6 Answers
It's perfectly possible to do it, back in the day (when there was no PHP around), many web applications were written in C++. There is a standard called CGI that facilitates communication between your application and your web server. This tutorial shows hot to set it up for an Apache web server, using Perl as the target language. You should be able to write a C++ program that prints out the same text and test it.
Databases can be accessed using C++ using a variety of libraries, depending on your needs and database system.
While all of this is totally possible, I'd be interested why you would do such a thing in the days of sophisticated frameworks and languages that are far more suited to web applications than C++. I'd certainly not recommend it.

- 4,502
- 1
- 27
- 34
If you mean by "run through the browser" to run native code in the browser the only way I know of to execute native code in the browser is Google's NaCl.
For server side C++ no special rules apply and it's very common. All normal rules for C++ application (including databases and linking) apply here.

- 58,701
- 10
- 113
- 156
If by "through the browser" you mean a webapp, yes - you can write CGI applications in C++, as in most other languages. See the answers to this question.
wt is a toolkit that may make it easier for you if you come from a desktop background.
About the portable database layer, take a look at these two questions. If all you need is a database that works across platforms, but don't need to be able to switch database engines across platforms, SQLite may be the way to go.

- 1
- 1

- 11,668
- 2
- 39
- 42
CGI or FastCGI for server side C++.
NaCl for client side C++.
Database connections with things like MySql Connector.
Any scripting langauge can run COM. You can create COM objects in C++ that you can invoke serverside from php.

- 4,111
- 1
- 25
- 24
Is it possible to create a C++ application that can be run trough the browser?
I'm not sure what you mean by "run through the browser" (or, for that matter, "C++ application"). pmr has already mentioned Google NaCl as one option. If "C++ application" includes C++ plugins, then "sure, you can." You can compile C++ to Javascript. If you're talking about web sites or web services, I can say "yes, it's possible; I maintain a web service that uses C++ for the backend, and Amazon was once written in C++, do you have any particular question?"
It's possible to write a lot of things in a Turing complete language. That doesn't mean it's a good idea.
Is there any way to link C++ application with a database (that can be used by both Mac, Linux and Windows).
Again, I'm not sure what you mean by "link ... with a database." You certainly can interact with a database using things like ODBC, DTL, LDAP or MongoDB. You also can embed a database in your program, using things like SQLite, MySQL embedded, Firebird embedded, Berkeley DB, LevelDB, or whatever Microsoft's calling Microsoft Jet these days. Do you have a particular question?

- 19,717
- 4
- 46
- 69