Which C++ Library for CGI Programming?

20,178

Solution 1

I'm not sure exactly what you're looking for, but there is a C++ web framework called wt (pronounced "witty"). It's been kept pretty much up to date and if you want robust C++ server-side code, this is probably what you're looking for.

You can check it out and read more at the wt homepage.

P.S. You may have some trouble installing wt if you don't have experience with *nix or C++ libraries. There are walkthroughs but since frameworks like these are the road less traveled, expect to hit a few bumps.

Solution 2

Another option is the Cgicc library which appears to be mature (currently at version 3.x):

http://www.gnu.org/software/cgicc/

Solution 3

If I were thinking of working at that level, I'd probably just write a straight-up Apache or IIS module instead of a CGI.

That said, if you do want to go with CGI, I'd suggest using the venerable cgic from Thomas Boutell. It's a "plain" C library, but it's been in constant use since the mid '90s so it's thoroughly tested and solid as a rock.

Solution 4

Check out Boost's C++ CGI class, which is not a part of boost yet.

Solution 5

In short, I don't think there is such a thing for generic server CGI programming (happy to be proven wrong of course).

Instead you'll probably have to target the server APIs, such as Apache's. This looks like a reasonable introduction to request processing, which will be a big part of what you're doing.

As an alternative, Lighttpd may be even more developer-friendly, and (particularly if you're looking at performance) faster.

I note there's a cpp-netlib under development but it seems to be HTTP client only.

Share:
20,178
Andre Gallo
Author by

Andre Gallo

Updated on July 18, 2022

Comments

  • Andre Gallo
    Andre Gallo almost 2 years

    I'm looking at doing some work (for fun) in a compiled language to run some simple tests and benchmarks against php.

    Basically I'd like to see what other people use for C++ CGI programming. (Including backend database, like mysql++ or something else)

  • Sherm Pendley
    Sherm Pendley over 15 years
    Yes, CGI is quite generic. That's the whole point, to standardize the interface between a web server and a child process that's launched to service a request. I've written CGIs with Turbo C using Bob Denny's HTTP server, for deployment on SGI servers running NCSA's, with no trouble at all.
  • Sherm Pendley
    Sherm Pendley over 15 years
    And yes, I realize how old it makes me sound, talking about Denny's server for Windows NT, and about the NCSA httpd that predates Apache. Get off my lawn! :-)
  • Andre Gallo
    Andre Gallo over 15 years
    I was originally looking at GNU Cgicc as it is GNUs, and therefore usually solid. They do exist for sure though, but going the 'direct to api' route is interesting as well.
  • Andre Gallo
    Andre Gallo over 15 years
    This looks almost exactly like what I was looking for, but I'm an avid JavaScript developer as well, My first impression (without research) is that this tries to do the JS for you. True?
  • dwlz
    dwlz over 15 years
    Well, I haven't used this framework myself, other than testing out the "Hello, World" app, but they maintain that you can. There's support for "custom JavaScript (e.g. for client-side only event handling), and emit C++ signals from this custom JavaScript." - webtoolkit.eu/wt#/features
  • unixman83
    unixman83 about 13 years
    The license of cgic is bad. Requires attribution or purchase of commercial license.
  • Sherm Pendley
    Sherm Pendley about 13 years
    It does have that requirement, but IMHO it isn't all that bad - all that's required is a simple note on your site's "credits" (or similar) page. They're not asking for a huge obnoxious banner on every page or something like that, LOL! :-)
  • unixman83
    unixman83 about 13 years
    FastCGI is a reasonable alternative to an Apache module. It supports C/C++.
  • unixman83
    unixman83 about 13 years
    Really big framework for me. Looks like it has a steep learning curve, or just a result of poor documentation (they use doxygen).
  • unixman83
    unixman83 almost 13 years
    -1, this is incorrect. Vanilla CGI is well supported by most web servers. But CGI does not scale well at all. FastCGI is a great alternative that keeps most of the semantics of CGI but scales much better.