Path: news.mathworks.com!not-for-mail
From: Brian Arnold <Brian.Arnold@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: create 32 bit mex files from 64 bit matlab?
Date: Tue, 06 Oct 2009 14:36:52 -0400
Organization: The MathWorks, Inc.
Lines: 59
Message-ID: <hag2o4$36c$1@fred.mathworks.com>
References: <ha50cg$nim$1@fred.mathworks.com> <7bc56d44-508b-4ada-b957-416fcf2f056c@z34g2000vbl.googlegroups.com>
NNTP-Posting-Host: dev02maci.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1254854212 3276 144.212.108.59 (6 Oct 2009 18:36:52 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 6 Oct 2009 18:36:52 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.21 (Macintosh/20090302)
In-Reply-To: <7bc56d44-508b-4ada-b957-416fcf2f056c@z34g2000vbl.googlegroups.com>
Xref: news.mathworks.com comp.soft-sys.matlab:575411


Hi,

Installing both maci and maci64 together on a Mac is supported, but 
cross-compiling a different architecture is not supported, and not 
advised.  You should always run the same architecture that you compile, 
so that you can test that what you compiled works.

If you have both architectures installed, you can control the MATLAB 
architecture to run using the "Open in 32-bit Mode" checkbox in the Get 
Info window for the MATLAB_R2009b application in the Finder.  To specify 
the architecture from Terminal or xterm, use 'matlab -maci' or 'matlab 
-maci64'.

With that said, it is actually possible to cross-compile :-). You only 
need both maci and maci64 installed, and 64-bit hardware.

The environment variable MACI64 can be used to control the architecture 
that the mex, mcc and matlab shell scripts default to. To change MEX to 
compile 32-bit mexmaci from 64-bit MATLAB, set the MACI64 environment 
variable to 0 before compiling with MEX. To change it back to compiling 
64-bit mexmaci64, set it to something other than 0.

Doing this has many hazards associated with it, so it's not supported, 
and my advice is that you always run the architecture you intend to 
compile, so that you can test your compiled code.

Good luck,

- Brian

Rune Allnor wrote:
> On 2 Okt, 15:49, "Sriram Swaminarayan" <sri...@lanl.gov> wrote:
>> platform: osx, intel
>> matlab: 7.9.0.529 (R2009b), 64-bit (maci64), August 12, 2009
>>
>> I want to create .mexmaci files using mex, but it looks like I have no way to create them using the mex that ships with this version of matlab.  
>>
>> Even if I use 'mex -arch maci ', it still only creates '.mexmaci64' files.
>>
>> Is there a simple way around this, or do I have to keep a 32 bit version of matlab around to create the '.mexmaci' files?
> 
> It depends on the compiler, which needs to be able to
> produce both 32-bit and 64-bit dlls and executables.
> Once you have such a compiler (not all compilers can
> do this), you will need to trick matlab/MEX to call the
> compiler in 32-bit mode instead of 64-bit mode. Which
> may or may not be possible.
> 
> Last, you might need to use matlab in 32-bit mode in
> order to test the MEX file.
> 
> It might be most convenient to install a 32-bit
> version of matlab on your 64-bit system, and do all
> the 32-bit mex stuff under this version.
> 
> Provided, of course, that a 64-bit and a 32-bit matlab
> can coexist on your system. Which may or may ot be the case.
> 
> Rune