Click here to Skip to main content
11,432,168 members (59,903 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
Hello all,
I am trying to run a 'simple' C++ program on a server. Before everyone says use PHP, Javascript... Its not that simple I am using libraries in C++ that are not available to PHP and Javascript.
So for example if I had a simple C++ program that created a file containing "Hello World!". Can someone explain a way in which I could run this program on a sever essentially putting this file on the server.

Hope that makes some sense.
Posted 23-Jan-13 6:46am
Comments
Sergey Alexandrovich Kryukov at 23-Jan-13 12:28pm
   
You can, but the server will hardly appreciate your greeting? Why?
And now, the rest of the answer totally depends on what server-side technology you use. Before you tell us what it is, there is nothing else to discuss.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Quote:
Before everyone says use PHP, Javascript... Its not that simple I am using libraries in C++ that are not available to PHP and Javascript

However you may use PHP system() function to call your executable.
  Permalink  
Comments
Marcus Kramer at 23-Jan-13 16:51pm
   
My 5
Espen Harlinn at 23-Jan-13 17:28pm
   
That should work :-D
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Use CGI, have a look at:
CGI[^]

Enabling FastCGI on IIS 7[^]

You could also work your way from one of the expample
http servers provided with the Boost C++ library[^]

Best regards
Espen Harlinn
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

PHP, JavaScript etc... run using the CGI[^] method.

Any executable can be run this way and it simply needs to return a valid HTML string.

But every web server has optimizations built in to speed up the execution of a url. That's likely where Sergey is coming from in his comment.

Imagine if you have a CGI process that takes 25 seconds to initialize, calculate the answer and then return. Then you start getting 100 hits a minute on that process... Your server performance is going to suffer tremendously.

To solve this problem, web servers will usually support DLLs as an extension for CGI scripts. You associate a file extension with the DLL, and that file and HTTP requests will be passed to a call in the DLL for processing.

Using this method, allows for pre-caching of the files, and pre-Loading DLLs. This saves quite a bit of time in handling requests.

To provide specific recommendations, we need to know what server you're using.
  Permalink  
Comments
Espen Harlinn at 23-Jan-13 17:47pm
   
Well answered :-D
jibesh at 23-Jan-13 17:56pm
   
my 5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.150428.2 | Last Updated 23 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100