Click to See Complete Forum and Search --> : C++ and CGI...
Java_Hunter
April 22nd, 1999, 05:32 PM
When you make a C++ CGI do you compile it?...
That sounds like a pretty stupid question but It has never been blankly said, and I wondered when I saw a PERL cgi...
Does anyone know of an "explain more then I want to know" site?
I want to learn how to use CGI's, I am currently pretty good with JavaScript but CGI is more compatible and more capable for the things I want to do...
Masaaki
April 22nd, 1999, 11:17 PM
Hi.
You must compile and make EXE file to C or C++.
Because Perl is a interpreter language, perl command handle
pl file.
As for me, I use perl to CGI partly because my school web server resides on Unix OS and perl gives me the shorter code than that of C++.
So which language is better on CGI?
It depends on OS of web server and your purpose.
But C and C++ is difficult to handle the string and their longer code.
On the other, perl is easier to handle it.
Regards.
-Masaaki Onishi-
Java_Hunter
April 23rd, 1999, 01:58 AM
Thankyou, now I wonder, do you need a cgi bin for c++ CGI's? or does the form just execute the exe?... (I am really intrested, but have found limited sources)
Jason Teagle
April 23rd, 1999, 02:38 AM
I think that the CGI has to be compiled into a _UNIX_ executable for it to work on a UNIX server, not a VC++ EXE!. I am also interested in how to do this, but finding a UNIX compiler that works under Windows is a joke. The only way I am aware of for doing this is to install a UNIX server on your PC! (Funny how UNIX runs on a Windows machine but REAL Windows won't run on a UNIX machine...)
Stefan Tchekanov
April 23rd, 1999, 03:46 AM
In C++ standard library there is a class called String which hanldes a lot of string manipulation needs. This class should be found in most C++ compilers.
>But C and C++ is difficult to handle the string
>and their longer code.
Perl interpreter is a .EXE (or UNIX executable) and it is much bigger than usual CGI written in C++.
1. When the web server is going to execute your Perl script it starts Perl interpreter (big code) and passes your script file name to it. This big code should be read from the disk into memory. (Exception of this rule would be when the web server is optimized for Perl execution and the Perl Interpreter is already in the memory. This would speed up the process of starting the Perl scripts but as I know there is not such a web server present at the moment.) Microsoft's web server (IIS) uses this technique to increase the performace of its ISAPI .DLLs.
2. When the web server is going to start your CGI written in C++ it just starts your .EXE and that's all.
3. I know a bit of Perl. Does Perl support database access? Could you access DB from Perl script? In C++ you can.
So starting a C++ CGI is much faster. The C++ CGI execution is much faster because it is native code execution.
But writing in C++ may be harder than in Perl.
So it really depends on your current needs, goals, OS and web server you have.
Emil
April 23rd, 1999, 05:33 AM
1. As others have said, a c/c++ CGI must be compiled in the same environment as the server (Unix or Win32 or...) and the compiled EXE is run by the webserver.
2. To handel the input string (from the form) in a nice way, you might consider to use CGIC (an ANSI C lib for CGI) which can be found at:
http://www.boutell.com/cgic/
I've used CGIC in Unix environment and it works great!
//E
---------------------------------------------
Emil Gustafsson
M.Sc. Computer Science
NTier Solutions AB
emil@ntier.se
Java_Hunter
April 30th, 1999, 12:04 AM
thankyou... I have found some sites with c cgi's but I have to go find them agian to see what type of interaction stuff they do...
Today cgi tomarrow the world!
Java_Hunter
April 30th, 1999, 12:08 AM
yes... too many choices, well I know C++ and I don't know Perl.
Thankyou for sharing your knowledge..
Can you use cout to output with cgi or is it only fprintf or whatever it's called.
Stefan Tchekanov
April 30th, 1999, 02:01 AM
>Can you use cout to output with cgi or is it only fprintf or whatever it's called.
Yes, you can use cout. cout is designed to be replacement for printf which is equal to fprintf( stdout, ... ). printf and fprintf are part of C standard library whereas cout is part of C++ standard library.
Stefan Tchekanov
April 30th, 1999, 02:13 AM
Look at http://www.cgi-resources.com/
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.