16

I've found only two FastCGI libraries for C++. There's the "official" one, and fastcgi++. How is either one better than the other? Do any others exist?

Gordon
  • 1,844
  • 4
  • 17
  • 32
  • 2
    Could be some good leads here: http://stackoverflow.com/questions/746309/which-is-the-best-c-web-framework – Assaf Lavie Nov 23 '09 at 08:41
  • 1
    @AssafLavie, Now how is that related. – Pacerier Jun 25 '15 at 05:30
  • 1
    I've recently found [Cutelyst](https://github.com/cutelyst/cutelyst) for C++/Qt which supports FastCGI. Rather easier than writing from scratch on top of raw FastCGI library :) – Gordon Mar 17 '17 at 17:36

6 Answers6

9

What you probably want is hidden in the contrib directory of Cgicc package.

fcgi-test.cpp is an example of how to use cgicc with FastCGI.

Path to the installed fcgi-test.cpp should be /usr/share/doc/libcgicc-doc/examples/contrib/fcgi-test.cpp

Korusef
  • 611
  • 6
  • 5
6

As fastcgi++ is still listed as "Development Status: 4- Beta" so I would suggest going for the official one. It has been around for ages and has bindings for a whole host of languages. Licences between the 2 don't seem to make much difference. Put some measurements in your code and if performance is an issue then spend some time playing around with alternatives.

roalz
  • 2,699
  • 3
  • 25
  • 42
Stuart Matheson
  • 490
  • 4
  • 4
  • 2
    fastcgi++ is in "Development Status: 5 - Production/Stable" since April 5, 2018. The official FastCGI is now unsupported and the website went away. – Daniel F Jun 11 '18 at 13:05
6

The official library is rather low-level, and as such, is only useful as an intermediate for a high-level CGI library such as cgicc.

Fastcgi++, on the other hand, allows for use of C++ idioms when dealing with FastCGI. Incompleteness in v1 motivated me to fork it into mosh-fcgi.

Pros: My fork complies with every point of the standard (especially ROLE_FILTER) everything's extensively templated, so it's easier to use arbitrary T for std::basic_strings. Cons: My modifications are in alpha mode.

In any case, download the latest zip from https://github.com/moshbear/mosh-fcgi.

moshbear
  • 3,282
  • 1
  • 19
  • 33
5

See also the Cgicc library:

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

The library appears to be mature (currently at version 3.x). According to the documentation it can be used with FastCGI by passing a custom reader (reader_function_t) to the constructor of the Cgicc class.

Yukiko
  • 1,113
  • 1
  • 8
  • 10
3

There is a pretty library for creating FastCGI daemons: https://github.com/golubtsov/Fastcgi-Daemon

Orofarne
  • 31
  • 1
2

The C-version of FastCGI does very little, and developing in C++ isn't such a big problem as it hardly interferes with your own code. It's most likely just a loop and an environment variable.

So my advice would be just to stick with the official version.

Just be aware of one thing: it works by redefining printf! So if you use cout it won't work.

Tristram Gräbener
  • 9,601
  • 3
  • 34
  • 50