32bit and 64bit compilations

Hi All,
I am trying to use matlab 2013a for making 32 bit and 64 bit compilations (with the matlab compiler).
The problem is that running "mbuild -setup" creates "compopts.bat" file in my application data folder: "...\AppData\Roaming\MathWorks\MATLAB\R2013a\compopts.bat". Unfortunately, the files are different and incompatible for the 32 and 64 bit versions.
Any simple way around it? I wouldn't like to run mbuild every time I start matlab.
Thanks, Silviu.

Risposte (3)

Mark Mikofski
Mark Mikofski il 29 Mag 2014
I've just noticed that R2014a no longer uses the same compopts.bat or mexopts.bat for both targets in AppData\Roaming\MathWorks\MATLAB\R2014a but instead now has separate xml files for 32-bit and 64-bit files called
mex_C_win32.xml
mex_C_win64.xml
MBUILD_C_win32.xml
MBUILD_C_win64.xml
Yay! Thanks TMW for hearing us and responding helpfully! I couldn't find it documented anywhere or in the release notes, but this is a nice if tiny improvement.

4 Commenti

Ken Atwell
Ken Atwell il 30 Mag 2014
Modificato: Image Analyst il 30 Mag 2014
Thanks for noticing! You got it exactly right: Beginning with R2014a, you no longer need to run 'mex -setup" when switching between 32- and 64-bit MATLAB, nor when switching between C and Fortran compilers.
In fact, you don't ever need to run 'mex -setup' at all; MEX will choose a compiler at run-time if you've never run 'mex -setup'. Going forward, 'mex -setup' is really needed only when you are unhappy with MEX's heuristic for choosing a compiler on-the-fly.
OK, now if we could just get it to compile 32 bit version while running a 64 bit version. I can't tell you how many times I've forgotten to compile in the 32 bit version only to have my 32 bit customer tell me "hey this doesn't work, it says something about 64 bit". Then I say "Oh darn, I forgot to switch to 32 bit to compile it." At least being able to specify target platform via a compile option would be more convenient than
  1. exiting my 64 bit MATLAB,
  2. running my 32 bit version,
  3. compiling and shipping to customer, then
  4. exit the 32 bit version, and finally,
  5. restarting my 64 bit version again.
Ken Atwell
Ken Atwell il 30 Mag 2014
@Image Analyst, we'll keep this in mind, but honestly I think it is unlikely we'd invest in this, as support for the 32-bit version of MATLAB is beginning to wind down (no definite sunset timeline has been set, but it will happen some time in the next few years).
John
John il 11 Feb 2015
I definitely agree with @Image Analyst, the need for compiling both 32 bit and 64 bit versions would be highly desireable

Accedi per commentare.

Image Analyst
Image Analyst il 17 Mar 2013
I don't think there's a way around this. Haven't checked lately but a while ago they told me that I had to run mbuild -setup every time I want to switch compiling to a different version (32 or 64) of MATLAB.
Well there might be a workaround. What I do is have a file called compile.m and in there I put a bunch of code to compile the m-file in that project folder with whatever options I want for that file. In there you could determine the version of MATLAB, and then copy over the proper version of the compopts.bat file. Haven't tried it but could be worth a shot.
howManyMATLABbits = str2double(howManyMATLABbits(4:5));
file32 = '...\AppData\Roaming\MathWorks\MATLAB\R2013a\compopts32.bat'
file64 = '...\AppData\Roaming\MathWorks\MATLAB\R2013a\compopts64.bat'
fileMaster = '...\AppData\Roaming\MathWorks\MATLAB\R2013a\compopts.bat'
if howManyMATLABbits == 32
copyfile(file32, fileMaster);
else
copyfile(file64, fileMaster);
end

2 Commenti

Thanks Image Analyst, your idea works very well.
Forgot to mention that I don't have the function howManyMATLABbits. I used instead
Platform = computer();
where Platform='PCWIN' for 32bit and Platform='PCWIN64' for 64 bit.
Thanks again, Silviu.

Accedi per commentare.

shamsudheen p
shamsudheen p il 16 Mag 2021

0 voti

I am getting the error message as 'Problem creating Accelerator MEX file for model 'PVarray_Grid_IncCondReg_det' during the simulation of 100-kW Grid-Connected PV Array using MATLAB 2013a on windows 10(32bit).
When i run mex -setup it gave the output as
Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2013a\sys\lcc
[0] None
Even I selected the first one the error persists. Please help me to solve the issue

Categorie

Prodotti

Richiesto:

il 17 Mar 2013

Risposto:

il 16 Mag 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by