mcc compiler errors for -win32 and -R -nojvm

Hello
I am using Matlab R2015a (x64 version) to compile my code to a DLL program. Some options set on the mcc compiler GUI produces the following errors:
Error: The option -win32 is invalid when executed from within MATLAB on "win64".
Error: The option -R is invalid in library or component mode (specify -? for help).
1) Howo can I compile my code as x32 DLL program?
2) How can I use -nojvm option for the DLL program?
Thank you.
Cem
ant:
<ant>
<mkdir dir="F:\user\Documents\Math\MATLAB\Work\ProgramV1.7\Program\for_redistribution" />
<mkdir dir="F:\user\Documents\Math\MATLAB\Work\ProgramV1.7\Program\for_testing" />
<mkdir dir="F:\user\Documents\Math\MATLAB\Work\ProgramV1.7\Program\for_redistribution_files_only" />
</ant>
mcc -win32 -R -nojvm -W cpplib:Program -T link:lib -d F:\user\Documents\Math\MATLAB\Work\ProgramV1.7\Program\for_testing -v F:\user\Documents\Math\MATLAB\Work\ProgramV1.7\Program.m -a F:\user\Documents\Math\MATLAB\Work\ProgramV1.7\get_metrics.m -a F:\user\Documents\Math\MATLAB\Work\ProgramV1.7\gridfit.m -a F:\user\Documents\Math\MATLAB\Work\ProgramV1.7\polygeom.m
Error: The option -win32 is invalid when executed from within MATLAB on "win64".
Error: The option -R is invalid in library or component mode (specify -? for help).
mcc failed.

Answers (1)

If I recall correctly there was a way to compile for windows 32 from within 64 bit MATLAB, by exchanging compilation scripts. Unfortunately the documentation for that is no longer available to me.
The main way to proceed is to install the 32 bit version of MATLAB and use it to compile. That was still possible in your release.

3 Comments

Cem
Cem on 11 Dec 2020
Edited: Cem on 11 Dec 2020
I do not know even the existing of such script sto be able to compile a 32 librfary wtityh 64 bit Matlab installation. Is tehre a way I can get those scripts? I tried compiling in command mode with no avail. Therefore, It seems that one needs the 32 bit version of Matlab to compile any m code as a DLL. But rhetorically, having a switch like -win32 is confusing: you cannot certainly create a 64 bit application in a 32 bit machine, but you should be able to compile a 32 bit application in a 64 bit machine by defining a switch like this. Otherwise, what is this switch defining? Without it, you can compile a 32 bit application in 32 bit Matlab, a 64 bit application in 64 bit Matlab. So the meaning of this switch should reflect the intended function: to be able to compile 32 bit application by a 64 Matlab.
What about the other error with the use of the -R -nojvm switch? The DLL program I use crashes if I do not replace the Java library in Matlab runtime installation with a recent version of Java in Win 10, even though I do not have any plots or Java requiring functions in my code. I thought with the use of this switch I would avoid any Java and use my program without the unnecessary hassle.
Thank you for your help.
Cem
There used to be a command you could run to toggle between compiling for 32 bit and 64 bit for windows, and the -win32 or -win64 switch had some kind of meaning then.
The -R flag is documented as
Provide MATLAB Runtime options. This option is relevant only when building standalone applications using MATLAB Compiler.
but you are building a dll not a standalone executable.
The switch has to do with whether to link the java libraries into the final executable, and nothing to do with whether java is invoked by the code. For example there is nothing along the lines of
if user asked not to link java
emit this code into the executable
else
emit this other code into the executable
end
The closest you get to that is that in some places the code is
if usejava('jvm')
execute this code that invokes java
else
execute this other code
end
the calls to the java functions being built into the executable, but the code being able to detect that java is not in fact available right now.
usejava() invokes system_dependent() which is built-in, so we do not know exactly how it operates. It probably operates along similar lines to
try
make a java status call
catch ME
that failed, guess java is not running
end
Great answer. Thank you.

Sign in to comment.

Products

Release

R2015a

Tags

Asked:

Cem
on 11 Dec 2020

Commented:

Cem
on 12 Dec 2020

Community Treasure Hunt

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

Start Hunting!