Link a web page to a C++ program

Hi all,

I have a C++ math program that I want to link to a web page. I want to share its output with some senior mathematics colleagues abroad that do not know any programming and are not likely to try to compile the source themselves.

What I want is:

One opens a web page (hosted on my university's servers). The web page offers some input fields and a button for computation. Once the button is activated, the server should run (on its own machine(s)) my C++ program passing it the input fields.

Once the computation is done, I want the web page to display a text returned by my program. If possible, I would also like to generate graphics for my user (but that is a later assignment).

How should I go about doing such a thing? What would you do if you were me?

I have 0 experience in any internet programming. I hope there is some simple enough solution that will be "easy" enough for a start. As a complete amateur programmer, I want to avoid as many as possible of the nasty technical details, if possible.

Thanks!

C++ is not big on web integration. If anything that's quite high level. Try js. You can also statically link the libraries and send the colleagues a compiled executable of your program instead. Such a program would be self-contained and would not require compilation or a redistributable library package.
if i were you and this is the case
The web page offers some input fields and a button for computation.
i will use javascript.. it's easy to learn if you have programming experience.


if this is the case
If possible, I would also like to generate graphics for my user
i would program it in java and display an applet on the user's web browser..
Applets are the best bet, no doubt.
If you really want to use your c++ program you must transform it in a cgi, but it's not so easy to do if didn't do it before. Perhaps I think you could do it in a few days or at last in a week of work with some cgi libraries like http://www.yolinux.com/TUTORIALS/LinuxTutorialC++CGI.html

You alse must know that work with graphics in c++ it's not so easy.

I don't know if you can do it with javascript because I don't know what have to do the program, but if you can't use js then you can use php for calculation e for graphics too and it's not so difficult to learn.

For graphics with php look at http://www.ibm.com/developerworks/library/os-objorient/
Try js. You can also statically link the libraries and send the colleagues a compiled executable of your program instead.


The program is already 20k lines of code and is heavily templated/subclassed, so rewriting it is another language is not an option for me.

and send the colleagues a compiled executable of your program instead

I did send them my compiled executables a few times but I constantly change stuff in the internal algorithm, so I want to be able to have on the site the very latest version that I experimented on. Both professors that are interested in my work are quite senior (60+) and use Macintoshes. I doubt they will actually try to run something unless it's *dead easy*.

Thanks a lot for the links!
Just another thing.You could construct the form with two buttons, the first button call your c++ cgi, the second button call the php page for the graphics reading the data calculated with the first button and written in a temporary file. You could pass the name of the file to the form and so perhaps it shouldn't be very difficult.
I have been trying for two days to run my program via cgi, but, as expected, I am banging my head against the wall.

I am running ubuntu latest updated version and I am brand new in the linux community. I am sure I am doing it all wrong, but anyways let me say what I've been trying:

1. I have set a console executable, called vp, to be located in folder /var/www/cgi-bin/
2. I have set /var/www/index.html to contain a template from raffo's links:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<HTML> 
<HEAD><TITLE>Test CGIcc form</TITLE></HEAD> 
<BODY bgcolor="#cccccc" text="#000000"> 
<H2>Test CGIcc form</H2> 
<P> 
<FORM method="POST" action="./cgi-bin/vp"> 
Value 1 :
<input type="text" name="value1"> 
<P> 
Value 2 :
<select name="value2"> 
   <option value="option1">Option 1
   <option value="option2">Option 2
   <option value="option3">Option 3
</select> 
<P> 
Value 3 :
<input type="radio" name="value3" value="button1" checked="checked">Button1
<input type="radio" name="value3" value="button2">Button2
 <input type="hidden" name="value4" value="data4"> 
<P> 
<input type="submit" value="Submit"> 
</FORM> 
</BODY> 
</HTML>

3. I open http//localhost with my favorite browser.
4. I click the sample button given by the above code.
5. My browser offers me to download the executable file.

Instead I want it to execute the file (on the server, with default user privileges).

How should I do this? What I am doing wrong - is there another command for making a program run on the server? I saw many configuration-y looking files in the folder /etc/apache2 . Is there some configuration that needs to be done there? (atm it has default settings).

Thanks!
Last edited on
Topic archived. No new replies allowed.