<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159796</link>
    <title>MATLAB Central Newsreader - starting engopen</title>
    <description>Feed for thread: starting engopen</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 23 Nov 2007 16:46:44 -0500</pubDate>
      <title>starting engopen</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159796#402794</link>
      <author>Thomas </author>
      <description>Folks,&lt;br&gt;
I need some inspiration. On my private machine (Windows XP, &lt;br&gt;
MS Visual C++ Express) the following code works fine:&lt;br&gt;
&lt;br&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br&gt;
#include "engine.h"&lt;br&gt;
int main()&lt;br&gt;
{&lt;br&gt;
Engine *ep;&lt;br&gt;
if (!(ep = engOpen("\0"))) {&lt;br&gt;
	fprintf(stderr, "\nCan't start MATLAB engine\n");&lt;br&gt;
	return EXIT_FAILURE;&lt;br&gt;
}&lt;br&gt;
engClose(ep);&lt;br&gt;
return EXIT_SUCCESS;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
On my machine at work MATLAB doesn't start. At both &lt;br&gt;
machines I have the same MATLAB version (7.5). At work I am &lt;br&gt;
using Windows, too. MATLAB is an environment variable and &lt;br&gt;
can start from any path. I have used "matlab \regserver".&lt;br&gt;
Here's the path of MATLAB on my machine&lt;br&gt;
&lt;br&gt;
C:\Program Files\MATLAB\R2007b\bin&lt;br&gt;
&lt;br&gt;
and here's my exe file generated by Visual C++ (it &lt;br&gt;
compiles, so no problems with the embedding of the header &lt;br&gt;
or the linking)...&lt;br&gt;
&lt;br&gt;
C:\Documents and Settings\t.mysurname\winEngine\release&lt;br&gt;
&lt;br&gt;
Maybe there is some more explicit way to start MATLAB. Or &lt;br&gt;
shall I use a *.bat file?&lt;br&gt;
It also doesn't seem to work if MATLAB is already open...&lt;br&gt;
Any ideas?&lt;br&gt;
Thomas&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Fri, 23 Nov 2007 17:24:56 -0500</pubDate>
      <title>Re: starting engopen</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159796#402803</link>
      <author>Thomas </author>
      <description>Ok, I have done some further research and here's what's &lt;br&gt;
going on:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
I see that Matlab boots up &lt;br&gt;
when engOpen("\0") is executed, but then Matlab immediately &lt;br&gt;
quits&lt;br&gt;
before execution passes to the next line. I have tried &lt;br&gt;
calling both&lt;br&gt;
"matlab /regserver" and "matlab /Automation" from the &lt;br&gt;
Windows command&lt;br&gt;
line; both call up Matlab, but then Matlab still quits when &lt;br&gt;
engOpen&lt;br&gt;
is called.&lt;br&gt;
&lt;br&gt;
I have no leads to determine the cause of the problem.&lt;br&gt;
&lt;br&gt;
Any suggestions?&lt;br&gt;
&lt;br&gt;
Thank you,&lt;br&gt;
Thomas&lt;br&gt;
&lt;br&gt;
compare with&lt;br&gt;
&lt;a href="http://www.code-hosting.com/Matlab/1552688-engOpen---"&gt;http://www.code-hosting.com/Matlab/1552688-engOpen---&lt;/a&gt;&lt;br&gt;
returns-NULL-after-upgrade-to-R14-SP3-on-XP&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Fri, 23 Nov 2007 20:31:54 -0500</pubDate>
      <title>Re: starting engopen</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159796#402831</link>
      <author>James Tursa</author>
      <description>On Fri, 23 Nov 2007 17:24:56 +0000 (UTC), "Thomas "&lt;br&gt;
&amp;lt;thomas.schmelzer.nospam@gmail.com&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt;Ok, I have done some further research and here's what's &lt;br&gt;
&amp;gt;going on:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;I see that Matlab boots up &lt;br&gt;
&amp;gt;when engOpen("\0") is executed, but then Matlab immediately &lt;br&gt;
&amp;gt;quits&lt;br&gt;
&amp;gt;before execution passes to the next line. I have tried &lt;br&gt;
&amp;gt;calling both&lt;br&gt;
&amp;gt;"matlab /regserver" and "matlab /Automation" from the &lt;br&gt;
&amp;gt;Windows command&lt;br&gt;
&amp;gt;line; both call up Matlab, but then Matlab still quits when &lt;br&gt;
&amp;gt;engOpen&lt;br&gt;
&amp;gt;is called.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;I have no leads to determine the cause of the problem.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;Any suggestions?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;Thank you,&lt;br&gt;
&amp;gt;Thomas&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;compare with&lt;br&gt;
&amp;gt;&lt;a href="http://www.code-hosting.com/Matlab/1552688-engOpen---"&gt;http://www.code-hosting.com/Matlab/1552688-engOpen---&lt;/a&gt;&lt;br&gt;
&amp;gt;returns-NULL-after-upgrade-to-R14-SP3-on-XP&lt;br&gt;
&lt;br&gt;
Here is the MATLAB doc on this:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;External Interfaces Reference    &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;engOpen (C)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Start MATLAB engine session&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;C Syntax&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#include "engine.h"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Engine *engOpen(const char *startcmd);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Arguments&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;startcmd&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String to start MATLAB process. On Windows, the startcmd string&lt;br&gt;
must be NULL.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
So here is what I use to open the engine on Windows XP:&lt;br&gt;
&lt;br&gt;
ep = engOpen( NULL );&lt;br&gt;
&lt;br&gt;
i.e., I am passing the NULL pointer to engOpen. You are not passing&lt;br&gt;
the NULL pointer to engOpen, you are passing a valid string, namely&lt;br&gt;
&lt;br&gt;
"\0"&lt;br&gt;
&lt;br&gt;
This is a string with a valid memory address containing two&lt;br&gt;
characters, the null character and another null character terminator.&lt;br&gt;
Not the same thing as I am doing or what MATLAB doc says.&lt;br&gt;
&lt;br&gt;
And remember the engine opens pointed to the default startup directory&lt;br&gt;
for MATLAB, which may not be the same directory as your c program. If&lt;br&gt;
you need help fixing that part let me know.&lt;br&gt;
&lt;br&gt;
James Tursa&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Sat, 24 Nov 2007 11:15:30 -0500</pubDate>
      <title>Re: starting engopen</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159796#402862</link>
      <author>Thomas </author>
      <description>James Tursa &amp;lt;aclassyguywithaknotac@hotmail.com&amp;gt; wrote in &lt;br&gt;
message &amp;lt;cjdek3lmoblqs33mibkf45l9bud8sil65v@4ax.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
James,&lt;br&gt;
changing from "\0" to NULL doesn't change the behaviour in &lt;br&gt;
my case. I have also tried strings like "matlab" or &lt;br&gt;
strings like "startMatlab" where startMatlab.bat is a file &lt;br&gt;
that can start Matlab and is located in the same folder as &lt;br&gt;
the *.exe file of my program.&lt;br&gt;
&lt;br&gt;
I think the problem is better described in my second &lt;br&gt;
posting where I describe that MATLAB starts but closes &lt;br&gt;
after a second. I wish I would know what's going on...&lt;br&gt;
&lt;br&gt;
Can you please help me on that issue:&lt;br&gt;
&amp;gt; And remember the engine opens pointed to the default &lt;br&gt;
startup directory&lt;br&gt;
&amp;gt; for MATLAB, which may not be the same directory as your &lt;br&gt;
c program. If&lt;br&gt;
&amp;gt; you need help fixing that part let me know.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
I have read the MATLAB documenation and I have wasted &lt;br&gt;
several hours with this problem. &lt;br&gt;
&lt;br&gt;
Best,&lt;br&gt;
Thomas&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Sun, 03 Feb 2008 17:21:01 -0500</pubDate>
      <title>Re: starting engopen</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159796#412696</link>
      <author>sfreeman </author>
      <description>&amp;gt; &lt;br&gt;
&amp;gt; Can you please help me on that issue:&lt;br&gt;
&amp;gt; &amp;gt; And remember the engine opens pointed to the default &lt;br&gt;
&amp;gt; startup directory&lt;br&gt;
&amp;gt; &amp;gt; for MATLAB, which may not be the same directory as your &lt;br&gt;
&amp;gt; c program. If&lt;br&gt;
&amp;gt; &amp;gt; you need help fixing that part let me know.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
with C-Code in Windows this works (needs afaik windows.h):&lt;br&gt;
&lt;br&gt;
char dir[MAX_PATH];&lt;br&gt;
GetCurrentDirectory(MAX_PATH,dir); /* get pwd*/&lt;br&gt;
... (insert engOpen with your error handling here) ...&lt;br&gt;
engEvalString(ep, strcat("cd ",dir)); /*change to directory&lt;br&gt;
first*/&lt;br&gt;
... (rest usage of engine) ...&lt;br&gt;
&lt;br&gt;
it is not vanilla, but it works :o)&lt;br&gt;
Mathworks could include a few more hints with c in the&lt;br&gt;
example section, I think...&lt;br&gt;
&lt;br&gt;
Regards,&lt;br&gt;
&lt;br&gt;
Rainer&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
