Thread Subject: create 32 bit mex files from 64 bit matlab?

Subject: create 32 bit mex files from 64 bit matlab?

From: Sriram Swaminarayan

Date: 2 Oct, 2009 13:49:04

Message: 1 of 5

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?

Regards,
Sriram

Subject: create 32 bit mex files from 64 bit matlab?

From: Dan Hensley

Date: 6 Oct, 2009 15:52:41

Message: 2 of 5

Sriram Swaminarayan wrote, On 10/2/2009 7:49 AM:
> 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?

The latter. The mex file needs to link against the appropriate 32bit
Matlab libraries, which are only available with the 32bit installation.

Dan

Subject: create 32 bit mex files from 64 bit matlab?

From: Rune Allnor

Date: 6 Oct, 2009 16:06:42

Message: 3 of 5

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

Subject: create 32 bit mex files from 64 bit matlab?

From: Bruno Luong

Date: 6 Oct, 2009 16:36:20

Message: 4 of 5

Dan Hensley <somewhere@over.there.invalid> wrote in message <hafp2q$dj4$1@news.eternal-september.org>...

> >
> > 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?

I echo Dan here: you need to keep the 32-bit version of Matlab and compile with it.

Bruno

Subject: create 32 bit mex files from 64 bit matlab?

From: Brian Arnold

Date: 6 Oct, 2009 18:36:52

Message: 5 of 5

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

Tags for this Thread

Everyone's Tags:

mex

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
mex Sriram Swaminarayan 2 Oct, 2009 09:54:03
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com