Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
32 bit matlab on 64 bit machine, mex files

Subject: 32 bit matlab on 64 bit machine, mex files

From: Nick

Date: 29 Mar, 2013 13:29:05

Message: 1 of 5

I have a 64 bit machine with an (older) 32 bit version of matlab installed on it. I am wondering if it is possible to execute 64-bit mex files (compiled on a 64-bit machine). It seems like this should be possible as the CPU has a 64 bit instruction set. If not, is there a way to interface with 64-bit code (e.g. compile it into a dll that the 32-bit mex function would call).

Subject: 32 bit matlab on 64 bit machine, mex files

From: James Tursa

Date: 29 Mar, 2013 13:50:05

Message: 2 of 5

"Nick" wrote in message <kj44v1$6f8$1@newscl01ah.mathworks.com>...
> I have a 64 bit machine with an (older) 32 bit version of matlab installed on it. I am wondering if it is possible to execute 64-bit mex files (compiled on a 64-bit machine). It seems like this should be possible as the CPU has a 64 bit instruction set. If not, is there a way to interface with 64-bit code (e.g. compile it into a dll that the 32-bit mex function would call).

No. There is no way to use 64-bit code in your 32-bit MATLAB. You need 32-bit mex functions for 32-bit MATLAB, and 64-bit mex functions for 64-bit MATLAB.

James Tursa

Subject: 32 bit matlab on 64 bit machine, mex files

From: Nick

Date: 29 Mar, 2013 14:23:04

Message: 3 of 5

"James Tursa" wrote in message <kj466d$an3$1@newscl01ah.mathworks.com>...
> "Nick" wrote in message <kj44v1$6f8$1@newscl01ah.mathworks.com>...
> > I have a 64 bit machine with an (older) 32 bit version of matlab installed on it. I am wondering if it is possible to execute 64-bit mex files (compiled on a 64-bit machine). It seems like this should be possible as the CPU has a 64 bit instruction set. If not, is there a way to interface with 64-bit code (e.g. compile it into a dll that the 32-bit mex function would call).
>
> No. There is no way to use 64-bit code in your 32-bit MATLAB. You need 32-bit mex functions for 32-bit MATLAB, and 64-bit mex functions for 64-bit MATLAB.
>
> James Tursa

One option would be to write the code in C++, compile it and make a call to it via the "system" command. This is pretty clunky, however, and may require passing data via files. Is there a more elegant way to do this?

Subject: 32 bit matlab on 64 bit machine, mex files

From: Steven_Lord

Date: 29 Mar, 2013 17:13:09

Message: 4 of 5



"Nick " <dsfadfa@aol.com> wrote in message
news:kj4848$hbq$1@newscl01ah.mathworks.com...
> "James Tursa" wrote in message <kj466d$an3$1@newscl01ah.mathworks.com>...
>> "Nick" wrote in message <kj44v1$6f8$1@newscl01ah.mathworks.com>...
>> > I have a 64 bit machine with an (older) 32 bit version of matlab
>> > installed on it. I am wondering if it is possible to execute 64-bit
>> > mex files (compiled on a 64-bit machine). It seems like this should be
>> > possible as the CPU has a 64 bit instruction set. If not, is there a
>> > way to interface with 64-bit code (e.g. compile it into a dll that the
>> > 32-bit mex function would call).
>>
>> No. There is no way to use 64-bit code in your 32-bit MATLAB. You need
>> 32-bit mex functions for 32-bit MATLAB, and 64-bit mex functions for
>> 64-bit MATLAB.
>>
>> James Tursa
>
> One option would be to write the code in C++, compile it and make a call
> to it via the "system" command. This is pretty clunky, however, and may
> require passing data via files. Is there a more elegant way to do this?

Two options are to recompile the MEX-file in the 32-bit version of MATLAB or
to install a 64-bit version of MATLAB on that machine. I understand you may
not _like_ those options, or they may not be possible (you don't have access
to the source code, for example) but those I think are the two non-hacky
ways to do what you're asking.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: 32 bit matlab on 64 bit machine, mex files

From: Nick

Date: 29 Mar, 2013 17:36:08

Message: 5 of 5

Thanks.
I do have the source code (I am writing it), the reason I am asking is that my c++ mex code is calling a 64 bit assembly function. I will look into ways of calling (if possible) 64 bit assembly code from a 32-bit c++ program.

"Steven_Lord" <slord@mathworks.com> wrote in message <kj4i35$l3l$1@newscl01ah.mathworks.com>...
>
>
> "Nick " <dsfadfa@aol.com> wrote in message
> news:kj4848$hbq$1@newscl01ah.mathworks.com...
> > "James Tursa" wrote in message <kj466d$an3$1@newscl01ah.mathworks.com>...
> >> "Nick" wrote in message <kj44v1$6f8$1@newscl01ah.mathworks.com>...
> >> > I have a 64 bit machine with an (older) 32 bit version of matlab
> >> > installed on it. I am wondering if it is possible to execute 64-bit
> >> > mex files (compiled on a 64-bit machine). It seems like this should be
> >> > possible as the CPU has a 64 bit instruction set. If not, is there a
> >> > way to interface with 64-bit code (e.g. compile it into a dll that the
> >> > 32-bit mex function would call).
> >>
> >> No. There is no way to use 64-bit code in your 32-bit MATLAB. You need
> >> 32-bit mex functions for 32-bit MATLAB, and 64-bit mex functions for
> >> 64-bit MATLAB.
> >>
> >> James Tursa
> >
> > One option would be to write the code in C++, compile it and make a call
> > to it via the "system" command. This is pretty clunky, however, and may
> > require passing data via files. Is there a more elegant way to do this?
>
> Two options are to recompile the MEX-file in the 32-bit version of MATLAB or
> to install a 64-bit version of MATLAB on that machine. I understand you may
> not _like_ those options, or they may not be possible (you don't have access
> to the source code, for example) but those I think are the two non-hacky
> ways to do what you're asking.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Tags for this Thread

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.

Contact us