Best method to create a c++ app to communicate with nginx
I think I will go forward with Nginx module devlopment http://www.evanmiller.org/nginx-modules-guide.html
Why ?
- It don't require any other library dependency like fastcgi and other.
- I can use all feature of nginx inside my module.
No one here seems to have addressed the actual question, though some nice work arounds have been offered. I've been able to build C++ modules for nginx with a couple of minor changes.
- Change the module source file name to end with
.cpp
so gcc realizes it is dealing with C++. - Make sure all your Nginx includes (e.g.
ngx_config.h
,ngx_core.h
, etc.) are wrapped with anextern "C" { }
structure. Similarly make sure any functions called through Nginx function pointers are declared with a wrapper. - Add
--with-ld-opt="-lstdc++"
to your "configure" invocation when setting up Nginx.
With those three steps your module should compile, build, link, and actually work.