<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Writing Deployable Code</title>
	<link>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/</link>
	<description>Loren Shure  works on design of the MATLAB language at &#60;a href="http://www.mathworks.com/"&#62;The MathWorks&#60;/a&#62;. She writes here about once a week on MATLAB programming and related topics. &#60;br&#62;&#60;br&#62;&#60;a href="/images/loren-full.jpg"&#62;&#60;img src="/images/loren.jpg"&#62;&#60;/a&#62;</description>
	<pubDate>Mon, 23 Nov 2009 00:28:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Tim Doyle</title>
		<link>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29874</link>
		<dc:creator>Tim Doyle</dc:creator>
		<pubDate>Wed, 19 Nov 2008 05:02:29 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29874</guid>
		<description>Regarding the distribution of the compiled code and the MCR. It is my understanding that the 'deploytool' GUI (which is new to R2008a??) creates a single install program for the compiled code written by the user AND the MCR. Thereby eliminating the need to distribute the MCR separately to the compiled code.

Is this correct?

Tim.

By the way the spam protection asking me the sum of 3 + 9 seems to think 12 is not the right answer!!! I've had to refresh to get a new question.</description>
		<content:encoded><![CDATA[<p>Regarding the distribution of the compiled code and the MCR. It is my understanding that the &#8216;deploytool&#8217; GUI (which is new to R2008a??) creates a single install program for the compiled code written by the user AND the MCR. Thereby eliminating the need to distribute the MCR separately to the compiled code.</p>
<p>Is this correct?</p>
<p>Tim.</p>
<p>By the way the spam protection asking me the sum of 3 + 9 seems to think 12 is not the right answer!!! I&#8217;ve had to refresh to get a new question.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Webb</title>
		<link>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29838</link>
		<dc:creator>Peter Webb</dc:creator>
		<pubDate>Mon, 03 Nov 2008 23:49:09 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29838</guid>
		<description>Tom,

1. Using ADDPATH in a startup.m file is generally not a good way to manage the use of libraries of M-files in compiled applications. Some alternatives:
* MCC's -a switch (as you noted above)
* Using a bundle file to automate the inclusion of -a switches on the MCC command line. See the Compiler's documentation: http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/f13-998373.html.
* Use ADDPATH in an interactive MATLAB session and then save the path (via SAVEPATH). This permanently modifies the MATLAB path, and therefore the path used by MCC.

2. Yes, the state of the path at COMPILE TIME is what matters. Any addpath/rmpath calls in the compiled code will have no effect on what gets included in the deployed application (though they may cause runtime errors for the deployed application, as indicated in the main body of this posting).

3. I'm not sure why the use of disp() should affect performance. This bears further investigation.

4. R2007b enhanced MATLAB's support for UNC paths, thereby masking the underlying problem: Microsoft DOS commands do not uniformly support UNC paths. MATLAB commands that use DOS commands cannot support UNC paths either. In MATLAB, cd to a UNC directory and then execute system('dir'); this command will fail because DOS doesn't support DIR when the current directory is a UNC path.</description>
		<content:encoded><![CDATA[<p>Tom,</p>
<p>1. Using ADDPATH in a startup.m file is generally not a good way to manage the use of libraries of M-files in compiled applications. Some alternatives:<br />
* MCC&#8217;s -a switch (as you noted above)<br />
* Using a bundle file to automate the inclusion of -a switches on the MCC command line. See the Compiler&#8217;s documentation: <a href="http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/f13-998373.html." rel="nofollow">http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/f13-998373.html.</a><br />
* Use ADDPATH in an interactive MATLAB session and then save the path (via SAVEPATH). This permanently modifies the MATLAB path, and therefore the path used by MCC.</p>
<p>2. Yes, the state of the path at COMPILE TIME is what matters. Any addpath/rmpath calls in the compiled code will have no effect on what gets included in the deployed application (though they may cause runtime errors for the deployed application, as indicated in the main body of this posting).</p>
<p>3. I&#8217;m not sure why the use of disp() should affect performance. This bears further investigation.</p>
<p>4. R2007b enhanced MATLAB&#8217;s support for UNC paths, thereby masking the underlying problem: Microsoft DOS commands do not uniformly support UNC paths. MATLAB commands that use DOS commands cannot support UNC paths either. In MATLAB, cd to a UNC directory and then execute system(&#8217;dir&#8217;); this command will fail because DOS doesn&#8217;t support DIR when the current directory is a UNC path.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom M</title>
		<link>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29696</link>
		<dc:creator>Tom M</dc:creator>
		<pubDate>Tue, 12 Aug 2008 22:16:26 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29696</guid>
		<description>I'm still somewhat confused and unfortunately have only limited access to the Compiler Toolbox so cannot simply guess-and-check-and-learn. So here goes:

1. My startup.m has an addpath call in it. When I build a project that calls a function that lives only in the directory that I've added, will the depfun magic find that function and add it to the mcc command-line? I know I can explicitly add it to the build command with either "-a" or by dropping the file into the "Other files" part of the deploytool, but my question is why the compiler can't grab the function at compile-time and automatically include it in the executable. (It seems that it can't.) If I just included the path with a "-I" would it work?

I understand the compiler has to "freeze" the M-code at compile-time, and can't use the path at run-time to dynamically locate and run new M-code sitting somewhere on disk. My question has to do with the "right" way to link in code from a library that I use across many projects. Do I have to "-a" every M-file in the library? What do I need to do so that I can rely on depfun to pick up the right functions (and maybe only those that it needs) with as little intervention as possible?

2. Similarly: It's only the state of the path at compile-time that matters, right? So both me and the compiler should/do ignore any addpath and rmpaths in the code that is to be compiled.

3. A different topic: We've seen some evidence that use of "disp()" a lot on in a stand-alone compiled application slows it down considerably, compared to running from the MatLab command-line. Turning off all disp statements makes a remarkable improvement. Haven't tried something like fprintf() instead yet. Does this make sense? If so, why? Or is something else going on? (Windows I/O buffering is mis-tuned, we're idiots,  . . .?)

4. Someone ("Dan K", above) mentioned "issues with UNC paths" but I didn't understand what was wrong with actually using UNC paths. We've just started doing this across a Windows network and it seems to work. This way we avoid the use of drive letters, which can be user- and logon-state- dependent. So why not use them . . .?

Thanks for helping clarify some very important points already,

-tom</description>
		<content:encoded><![CDATA[<p>I&#8217;m still somewhat confused and unfortunately have only limited access to the Compiler Toolbox so cannot simply guess-and-check-and-learn. So here goes:</p>
<p>1. My startup.m has an addpath call in it. When I build a project that calls a function that lives only in the directory that I&#8217;ve added, will the depfun magic find that function and add it to the mcc command-line? I know I can explicitly add it to the build command with either &#8220;-a&#8221; or by dropping the file into the &#8220;Other files&#8221; part of the deploytool, but my question is why the compiler can&#8217;t grab the function at compile-time and automatically include it in the executable. (It seems that it can&#8217;t.) If I just included the path with a &#8220;-I&#8221; would it work?</p>
<p>I understand the compiler has to &#8220;freeze&#8221; the M-code at compile-time, and can&#8217;t use the path at run-time to dynamically locate and run new M-code sitting somewhere on disk. My question has to do with the &#8220;right&#8221; way to link in code from a library that I use across many projects. Do I have to &#8220;-a&#8221; every M-file in the library? What do I need to do so that I can rely on depfun to pick up the right functions (and maybe only those that it needs) with as little intervention as possible?</p>
<p>2. Similarly: It&#8217;s only the state of the path at compile-time that matters, right? So both me and the compiler should/do ignore any addpath and rmpaths in the code that is to be compiled.</p>
<p>3. A different topic: We&#8217;ve seen some evidence that use of &#8220;disp()&#8221; a lot on in a stand-alone compiled application slows it down considerably, compared to running from the MatLab command-line. Turning off all disp statements makes a remarkable improvement. Haven&#8217;t tried something like fprintf() instead yet. Does this make sense? If so, why? Or is something else going on? (Windows I/O buffering is mis-tuned, we&#8217;re idiots,  . . .?)</p>
<p>4. Someone (&#8221;Dan K&#8221;, above) mentioned &#8220;issues with UNC paths&#8221; but I didn&#8217;t understand what was wrong with actually using UNC paths. We&#8217;ve just started doing this across a Windows network and it seems to work. This way we avoid the use of drive letters, which can be user- and logon-state- dependent. So why not use them . . .?</p>
<p>Thanks for helping clarify some very important points already,</p>
<p>-tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Webb</title>
		<link>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29690</link>
		<dc:creator>Peter Webb</dc:creator>
		<pubDate>Tue, 12 Aug 2008 14:42:07 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29690</guid>
		<description>Stephen,

Compiled MATLAB applications are similar to Java programs and .NET assemblies. All three of these kinds of applications require relatively large virtual machines to run them: Java applications need the JVM, .NET assemblies require the CLR and MATLAB applications need the MCR.

That architecture does not lend itself to single file solutions. You could, of course, package the MCR with each of your executables or shared libraries, and each of your users could install it locally. You might also be able to install the MCR locally on your machine and then share the installation directory across your internal network.

There is currently no way to build a single binary that contains all the code required for a MATLAB Compiler-generated application; we don't support static linking because of the inefficiencies it creates.</description>
		<content:encoded><![CDATA[<p>Stephen,</p>
<p>Compiled MATLAB applications are similar to Java programs and .NET assemblies. All three of these kinds of applications require relatively large virtual machines to run them: Java applications need the JVM, .NET assemblies require the CLR and MATLAB applications need the MCR.</p>
<p>That architecture does not lend itself to single file solutions. You could, of course, package the MCR with each of your executables or shared libraries, and each of your users could install it locally. You might also be able to install the MCR locally on your machine and then share the installation directory across your internal network.</p>
<p>There is currently no way to build a single binary that contains all the code required for a MATLAB Compiler-generated application; we don&#8217;t support static linking because of the inefficiencies it creates.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Webb</title>
		<link>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29689</link>
		<dc:creator>Peter Webb</dc:creator>
		<pubDate>Tue, 12 Aug 2008 14:35:41 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29689</guid>
		<description>Prasanna,

You can't make the DOS command window go away, but you can make it start up minimized:

http://www.mathworks.com/support/solutions/data/1-1W0CIG.html?solution=1-1W0CIG</description>
		<content:encoded><![CDATA[<p>Prasanna,</p>
<p>You can&#8217;t make the DOS command window go away, but you can make it start up minimized:</p>
<p><a href="http://www.mathworks.com/support/solutions/data/1-1W0CIG.html?solution=1-1W0CIG" rel="nofollow">http://www.mathworks.com/support/solutions/data/1-1W0CIG.html?solution=1-1W0CIG</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen Hole</title>
		<link>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29682</link>
		<dc:creator>Stephen Hole</dc:creator>
		<pubDate>Tue, 12 Aug 2008 06:37:18 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29682</guid>
		<description>Working in a corporate environment and I being a Matlab user in minority, it is difficult to get the MCR "officially" installed. Also having an update every 6 months would be difficult to move forward. Is there a way to create compiled applications so that they are fully transportable? Single EXE or single directory? Adding registry entries etc. is also out of the question.
... any suggestions or other comments?</description>
		<content:encoded><![CDATA[<p>Working in a corporate environment and I being a Matlab user in minority, it is difficult to get the MCR &#8220;officially&#8221; installed. Also having an update every 6 months would be difficult to move forward. Is there a way to create compiled applications so that they are fully transportable? Single EXE or single directory? Adding registry entries etc. is also out of the question.<br />
&#8230; any suggestions or other comments?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: prasanna</title>
		<link>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29637</link>
		<dc:creator>prasanna</dc:creator>
		<pubDate>Sun, 03 Aug 2008 14:48:26 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29637</guid>
		<description>Why is it that compiled exe from matlab open invariably a command window? . is there any way to get gui of the compiled program directly start on the user system.

1. or only way to get rid of this problem is to get our programs compiled into dll and use VB or other programs for front end /gui and call these gui.
does this not seem a drawback/limitation .

kindly throw some light on the issue.</description>
		<content:encoded><![CDATA[<p>Why is it that compiled exe from matlab open invariably a command window? . is there any way to get gui of the compiled program directly start on the user system.</p>
<p>1. or only way to get rid of this problem is to get our programs compiled into dll and use VB or other programs for front end /gui and call these gui.<br />
does this not seem a drawback/limitation .</p>
<p>kindly throw some light on the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Webb</title>
		<link>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29624</link>
		<dc:creator>Peter Webb</dc:creator>
		<pubDate>Mon, 28 Jul 2008 15:59:06 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29624</guid>
		<description>Marcial,

Yes, the exclusion of ARMAX from your application is a result of licensing; because the ARMAX function performs model estimation, it cannot be deployed. 

For more details on the deployability of toolbox functions, see the &lt;a href="http://www.mathworks.com/products/compiler/compiler_support.html" rel="nofollow"&gt;  toolbox deployability table&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Marcial,</p>
<p>Yes, the exclusion of ARMAX from your application is a result of licensing; because the ARMAX function performs model estimation, it cannot be deployed. </p>
<p>For more details on the deployability of toolbox functions, see the <a href="http://www.mathworks.com/products/compiler/compiler_support.html" rel="nofollow">  toolbox deployability table</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcial Contreras</title>
		<link>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29619</link>
		<dc:creator>Marcial Contreras</dc:creator>
		<pubDate>Sun, 27 Jul 2008 21:42:20 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29619</guid>
		<description>Hi, so is it a licensing issue that I get this:

C:\Archivos de programa\MATLAB\R2007b\toolbox\ident\ident\armax.m
  called by C:\MATLAB\GUI\DEst.m
(because of toolbox compilability rules)

in the excluded files log?

armax its supposed to be used in a standalone windows application I'm trying to deploy.

Thanks</description>
		<content:encoded><![CDATA[<p>Hi, so is it a licensing issue that I get this:</p>
<p>C:\Archivos de programa\MATLAB\R2007b\toolbox\ident\ident\armax.m<br />
  called by C:\MATLAB\GUI\DEst.m<br />
(because of toolbox compilability rules)</p>
<p>in the excluded files log?</p>
<p>armax its supposed to be used in a standalone windows application I&#8217;m trying to deploy.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike N</title>
		<link>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29605</link>
		<dc:creator>Mike N</dc:creator>
		<pubDate>Fri, 18 Jul 2008 20:53:45 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/06/19/writing-deployable-code/#comment-29605</guid>
		<description>Should it be OK to use "persistent" variables in a deployed application?  What if I have two copies of the program running at once?</description>
		<content:encoded><![CDATA[<p>Should it be OK to use &#8220;persistent&#8221; variables in a deployed application?  What if I have two copies of the program running at once?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
