On 8/9/07, Jonathan Bober <[EMAIL PROTECTED]> wrote: > On Tue, 2007-08-07 at 23:37 -0700, Yigal wrote: > > Hi, > > I'm building web site for interactive solving school math problems > > using C++ CGI and open source math software. > > As I've been told in maxima mailing list, instead of reinventing the > > weel, i.e. carrying for interfaces to several CAS and other math > > software (GiNaC, Pari, Maxima, Octave and so on), I should use SAGE. > > So my question is, how can I use SAGE from within C++ CGI? > > I don't know if it is possible. If it is possible, then the correct > question is probably "How can I use Python from within C++?"
One can use Python from within C/C++. Doing this is explained here: http://docs.python.org/ext/embedding.html If one were to embed SAGE, it would be the same as embedding Python, except one has to be careful to (1) make sure the SAGE cleaner is or gets started (to clean up zombie child processes), and (2) make sure certain environment variables are set. I have never written an example standalone C program that embeds SAGE. I've always meant to write one as an example for the SAGE programming guide or the SAGE_ROOT/examples directory. If anybody wants to do so and post the result, it would probably be a great exercise for them. Regarding the rest of your post -- you're right, it would make way more sense to use the Python cgi module than to embed SAGE, at least if the user doesn't already have a huge C++ cgi-bin script. If they do, then embedding SAGE is probably the way to go. > > Or may be I > > should change the concept and to choose other CGI options like PHP or > > Perl for it? > > If you want to use SAGE, then the correct answer is, probably, just use > SAGE. More specifically, python has built-in support for CGI through the > cgi module: > > http://docs.python.org/lib/module-cgi.html > > and SAGE is built on top of python. So you should be able to use > everything in the cgi module (or any other python module) just fine from > within SAGE. (Alternately, you may think of SAGE as just python with a > bunch of extra modules preloaded.) > > > Thanks for the help in advance. > > Yigal Asnis > > > > > > > > > > > > > > > > -- William Stein Associate Professor of Mathematics University of Washington http://www.williamstein.org --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~----------~----~----~----~------~----~------~--~---