开发者

Apache mod_c++ wanted?

开发者 https://www.devze.com 2022-12-16 23:02 出处:网络
I want to experim开发者_运维技巧ent a bit with C++ as a server side language. I\'m not looking for a framework, and simply want to achieve a silly old \"Hello World\" webapp using C++.

I want to experim开发者_运维技巧ent a bit with C++ as a server side language. I'm not looking for a framework, and simply want to achieve a silly old "Hello World" webapp using C++.

Is there an Apache HTTP server module that I can install?

If i can do the PHP equivalent of :

<?php 
    $personName = "Peter Pan";
    echo "Hello " . $personName;

I'd be most thrilled! Thanks in advance!


cgi would do this. Just have your C++ app spit its output to stdout and your mod_cgi will handle it


You might want to have a look at http://www.webtoolkit.eu/wt or www.tntnet.org instead.


"mod_c++" doesn't make sense; Once you're talking about compiled programs, Apache doesn't care what language the binary comes from. mod_cgi allows Apache to invoke such a binary (regardless of it's source language) in response to HTTP requests. Read more here:

http://library.thinkquest.org/16728/content/cgi/cplusplus.html


Suppose for the moment the OP wanted something that was "like mod_php, mod_perl". Given the right configuration, it would be monumentally easy for the "mod_c++" to look at the source files, and compiled files and decide whether it had to do a "one off" compilation task. In fact this is how make works.

I know the OP probably didn't mean that it had to be "interpreted", but it's certainly not impossible to allow apache to compile cpp files on the fly if needed [this is how jsp works, btw].


I did create a mod_cpp once. It basically was written in c, but loaded a .so which was in turn written in C++.

Its performance was really good, but lacked a lot of things that we take for granted in things like PHP (sessions, HTML un/escaping, etc). It did use a template engine to separate the HTML from the C++.

I tell you, the initial set-up was a lot of work (the mod_cpp part); after that, it was kinda easy to write the .so's. I even tried to create an sf.net project to open-source it, but I never got around to actually porting it :-(

In summary: I did not find anything like that on the net, did it myself and found out to be a lot more work then I anticipated, but the result was very cool! This helped me a lot: Apache Modules


I'm not saying there is no such thing, but if there is it would be monumentally inefficient. C++ is a compiled language, not an interpretive one, so the putative Apache C++ module would have to invoke the C++ compiler to compile the code before executing it. This would be very, very slow, apart from other problems.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号