<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - comments on Post, EvalMapleStatement(CodeGeneration[C](...)) not working from C++ application</title>
    <link>http://www.mapleprimes.com/posts/37001-EvalMapleStatementCodeGenerationC</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Fri, 12 Jun 2026 00:50:43 GMT</lastBuildDate>
    <pubDate>Fri, 12 Jun 2026 00:50:43 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest comments added to the Post, EvalMapleStatement(CodeGeneration[C](...)) not working from C++ application</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - comments on Post, EvalMapleStatement(CodeGeneration[C](...)) not working from C++ application</title>
      <link>http://www.mapleprimes.com/posts/37001-EvalMapleStatementCodeGenerationC</link>
    </image>
    <item>
      <title>CodeGeneration[C] prints its result</title>
      <link>http://www.mapleprimes.com/posts/37001-EvalMapleStatementCodeGenerationC?ref=Feed:MaplePrimes:EvalMapleStatement(CodeGeneration[C](...)) not working from C++ application:Comments#comment64738</link>
      <itunes:summary>&lt;p&gt;CodeGeneration[C] prints its result, not sure whether you can re-direct that into a variable holding the text string(s).&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, EvalMapleStatement(CodeGeneration[C](...)) not working from C++ application</description>
      <guid>64738</guid>
      <pubDate>Thu, 23 Jul 2009 23:04:37 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>Maple's omexample.c does not work either...</title>
      <link>http://www.mapleprimes.com/posts/37001-EvalMapleStatementCodeGenerationC?ref=Feed:MaplePrimes:EvalMapleStatement(CodeGeneration[C](...)) not working from C++ application:Comments#comment64739</link>
      <itunes:summary>&lt;p&gt;Thanks, Axel, for your reply!&lt;br /&gt;
&lt;br /&gt;
As far as the application I am concerned with does, it 'asks' Maple to redirect its output to stdout, so then it can 'capture' the output (in this case, the generated code).&lt;br /&gt;
&lt;br /&gt;
In the meantime between my post and your reply, I have tried to build and run the example provided with Maple that does something similar to my application to acess Maple from C code. The source code for the example can be found at &lt;b&gt;$MAPLE_ROOT/samples/OpenMaple/cmaple/omexample.c&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This example provides a 'fake' Maple command prompt, and underneath, uses the &lt;b&gt;EvalMapleStatement()&lt;/b&gt; function to ask the 'real' Maple to perform the command typed at the prompt, and return the result.&lt;br /&gt;
&lt;br /&gt;
Here is the compile command line, output warnings (do not care for them) and sample session with the example program (I tried with and without &lt;b&gt;-lm -lc -lgmp -lmaple&lt;/b&gt; within the switches, to try if there was any difference; there was not):&lt;/p&gt;
&lt;p&gt;---------------------------------------&lt;/p&gt;
&lt;p style="margin-left: 40px;"&gt;&lt;b&gt;sancheg@mills:~/Projects/virtlab/svn/mapleclient/src$&amp;nbsp; gcc -g -Wall -Wchar-subscripts -Wpointer-arith -Wcast-align -Wsign-compare -Wno-switch -I./ -I/usr/local/maple11/extern/include -L./ -L/usr/local/maple11/bin.X86_64_LINUX -Xlinker -rpath -Xlinker /usr/local/maple11/bin.X86_64_LINUX -lmaplec -lc -lm -lgmp -lmaple omexample.c -o omexample&lt;br /&gt;
omexample.c: In function 'main':&lt;br /&gt;
omexample.c:115: warning: implicit declaration of function 'strlen'&lt;br /&gt;
omexample.c:115: warning: incompatible implicit declaration of built-in function 'strlen'&lt;br /&gt;
omexample.c:115: warning: implicit declaration of function 'isspace'&lt;br /&gt;
&lt;br /&gt;
sancheg@mills:~/Projects/virtlab/svn/mapleclient/src$ ./omexample&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; |\^/|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Maple (Example Program)&lt;br /&gt;
._|\|&amp;nbsp;&amp;nbsp; |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2004&lt;br /&gt;
&amp;nbsp;\OPENMAPLE/&amp;nbsp; All rights reserved. Maple and OpenMaple are trademarks of&lt;br /&gt;
&amp;nbsp;&amp;lt;____ ____&amp;gt;&amp;nbsp; Waterloo Maple Inc.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type ? for help.&lt;br /&gt;
&amp;gt; ?&lt;br /&gt;
&amp;gt; ?CodeGeneration&lt;br /&gt;
&amp;gt; 3*4;&lt;br /&gt;
12&lt;br /&gt;
&amp;gt; with(CodeGeneration);&lt;br /&gt;
with(CodeGeneration)&lt;br /&gt;
&amp;gt; CodeGeneration[C](2*x^3,resultname=y);&lt;br /&gt;
CodeGeneration[C](2*x^3,resultname = y)&lt;br /&gt;
&amp;gt; quit;&lt;br /&gt;
kilobytes used=45, alloc=31, time=0.00&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;---------------------------------------&lt;br /&gt;
&lt;br /&gt;
As you see, the simple arithmetic operation is carried out, but any other function does not. Not even the '&lt;b&gt;?&lt;/b&gt;' can trigger the help messages. And the output from Maple is effectively being 'captured' and displayed, which you can guess by the '&lt;b&gt;12&lt;/b&gt;' answer for the '&lt;b&gt;3*4;&lt;/b&gt;' command.&lt;br /&gt;
&lt;br /&gt;
So it seems that it is not only the &lt;b&gt;CodeGeneration&lt;/b&gt;&lt;b&gt;[C]()&lt;/b&gt; command that does not work.&lt;br /&gt;
&lt;br /&gt;
There must be some problem with Maple itself in the system I am running it -perhaps licensing issues- that the linking process for the application is not aware of, but that at runtime impedes the execution of some Maple toolboxes or modules or whatever (I have never used Maple before, as you will have already noticed). The same commands typed at the 'real' Maple command line work OK.&lt;br /&gt;
&lt;br /&gt;
I will anyway check the possibiity that the output is being misdirected. The thing that stil bothers me is that the exact same code worked perfectly OK before, and I have found no differences in the commands between Maple v9.5 and Maple v.11..&lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
&lt;br /&gt;
gonzalo&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, EvalMapleStatement(CodeGeneration[C](...)) not working from C++ application</description>
      <guid>64739</guid>
      <pubDate>Fri, 24 Jul 2009 01:11:35 Z</pubDate>
      <itunes:author>gonzalo</itunes:author>
      <author>gonzalo</author>
    </item>
    <item>
      <title>I think it just does what I said</title>
      <link>http://www.mapleprimes.com/posts/37001-EvalMapleStatementCodeGenerationC?ref=Feed:MaplePrimes:EvalMapleStatement(CodeGeneration[C](...)) not working from C++ application:Comments#comment64740</link>
      <itunes:summary>&lt;p&gt;I think it just does what I said: the command prints (like lprint), but does not return a result that way.&lt;/p&gt;
&lt;p&gt;Just try it in a sheet before&lt;/p&gt;
&lt;pre&gt;
&amp;nbsp; v:=CodeGeneration[C](2*x^3,resultname = y);
&amp;nbsp; v;
&amp;nbsp; lprint(v);
&lt;/pre&gt;
&lt;p&gt;The firts command assigns NULL to v. While the following may give you a start&lt;br /&gt;
to process the results by working with strings:&lt;/p&gt;
&lt;pre&gt;
&amp;nbsp; v:=CodeGeneration[C](2*x^3,resultname = y,output=string);

&amp;nbsp; v := &amp;quot;y = 0.2e1 * pow(x, 0.3e1);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot;

&lt;/pre&gt;
&lt;p&gt;Have not tried examples, since I have not set my IDE to use Maple.&lt;br /&gt;
&lt;br /&gt;
PS: seems to me, that in the past you may have used an undocumented feature,&lt;br /&gt;
which can not be expected to work over releases&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, EvalMapleStatement(CodeGeneration[C](...)) not working from C++ application</description>
      <guid>64740</guid>
      <pubDate>Sat, 25 Jul 2009 22:07:07 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>Code OK; problem derives from installation/licensing issues</title>
      <link>http://www.mapleprimes.com/posts/37001-EvalMapleStatementCodeGenerationC?ref=Feed:MaplePrimes:EvalMapleStatement(CodeGeneration[C](...)) not working from C++ application:Comments#comment64741</link>
      <itunes:summary>&lt;p&gt;Axel,&lt;/p&gt;
&lt;p&gt;Forgive me the delay in answering, but I was waiting for authorization to purchase a Maple license to test it locally, with 'full control' over the license and installation.&lt;/p&gt;
&lt;p&gt;I have just installed Maple locally, built the test code, and it works OK. So, definitely, there must be a problem with the license/installation details on the server we were using Maple from, which does not enable all of Maple's features.&lt;/p&gt;
&lt;p&gt;If I get to know which is the cause of the problem, I'll follow up this posts with the details, just in case any other user happens to run into a similar problem, but for the time being, I have not been able to determine what exactly is happening.&lt;/p&gt;
&lt;p&gt;Thanks for the time you dedicated to aid us, we really appreciate it!&lt;/p&gt;
&lt;p&gt;gonzalo&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, EvalMapleStatement(CodeGeneration[C](...)) not working from C++ application</description>
      <guid>64741</guid>
      <pubDate>Thu, 30 Jul 2009 10:22:41 Z</pubDate>
      <itunes:author>gonzalo</itunes:author>
      <author>gonzalo</author>
    </item>
  </channel>
</rss>