Which C++ Library for CGI Programming?

2019-01-21 23:25发布

问题:

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)

回答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.



回答2:

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.



回答3:

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

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



回答4:

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



回答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.



回答6:

I've found very pleasant to use CppCMS to develop a Fast CGI app to deploy in a nginx server - although it never went in production =( . The CppCMS project also includes some libraries for SQL connectivity.



标签: c++ cgi