I have been using the deploytool in Matlab for the past few months in my 2010b 64bit version of Matlab. I just recently found out that I need to create a 32 bit version of my c shared library.
To do this I follow the same methods I had been using previously (pretty much calling the command mcc -W lib:MYLIB -T link:lib -d 'MYOUTPUTFOLDER' -v 'MFILE1' 'MFILE2') in my 2009b 32 version of Matlab. I keep getting the error LNK1811: cannot open input file LIBRARY.obj. I have tried to find this LIBRARY object file but I cannot seem to find it anywhere.
So far I have checked to ensure all of the correct libraries are available (found at $MATLABROOT$\extern\include\win32), I have made sure all of my paths are correct in the compopts.bat file, and I have used the option -T compile:lib which works fine and creates a dll. This would be great but I need a lib file to use later in mbuild.
My current path forward is to take the compopts from my 64 bit version of Matlab (on a different machine) and compare it with my compopts for the 32 bit. I will post if it makes a difference.
1 Answer 1
To summarize our comments in the question and make it an answer. Here is how I manage to create both x32 and x64 libraries/standalones with mcc.
NB: Maybe there are more elegant solutions to configure deploytool, anyway with brute force I'm sure it works and I can automate global deployment process for my applications ...
Machine setup
- Install Matlab x32 and x64 on your machine
Run Matlab x32 and setup compiler options typing
msbuild -setup- This will generate a
compopts.batfile in~user\AppData\Roaming\MathWorks\MATLAB\R2013b(path may differ upon your version) - Rename this file to
compopts.x32.bat(see later)
- This will generate a
Run Matlab x64 and setup compiler options typing
msbuild -setup- This will generate a
compopts.batfile in~user\AppData\Roaming\MathWorks\MATLAB\R2013b(!!Overwrites x32!!) - Rename this file to
compopts.x64.bat(To workaround file overwrite)
- This will generate a
EDIT Just tested ... In R2014b, Matlab does no longer overwrites same compots.bat file ... it now generates two separate MBUILD_C++_win64.xml and MBUILD_C++_win32.xml files (which is a good thing!).
Compilation in x32
Force your compilation script to point to ~matlabx32\bin\win32\mcc.exe and force mcc.exe to use previously saved compopts.x32.bat file using the -f option. Your command line should be something like:
~matlabx32\bin\win32\mcc.exe -f "compopts.x32.bat" ... other mcc options ...
Compilation in x64
Force your compilation script to point to ~matlabx64\bin\win64\mcc.exe and force mcc.exe to use previously saved compopts.x64.bat file using the -f option. Your command line should be something like:
~matlabx64\bin\win64\mcc.exe -f "compopts.x64.bat" ... other mcc options ...
Comments
Explore related questions
See similar questions with these tags.
mccfrom the dos shell. May be forcing for $MATLABROOT$\bin\win32\mcc.exe and for expectedcompopts.x32.batfile with-foption. When compiling for both arch from same machine, matlab overwrites samecompopts.bat(lettingmbuild -setupcreate it for me) ... so i ended up forcing everything in my deploying scripts ... well here you say you're using two separate machines :( ...~\win32\mcc.exeor~\win64\mcc.exe. Forcompopts.batfile, I created one with matlab x64 (mbuild -setup=> renamed tocompopts.x64.bat) and one with matlab x32 (mbuild -setup=> renamed tocompopts.x64.bat). I then again force correct one on mcc command line with the-foption (If not specified mcc.exe uses last generatedcompopts.bat[and as matlab x64/x32 generate this file on same disk location it can be the wrong one])compopts.x32.batof courselccas compiler, and for x32 I useVS2012. I Would have like to uselccin both cases (to avoid having to deploy VC redistributables), but unfortunately matlab does not provide forlccin x64 mode (R2013b for me).