1

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.

asked Feb 12, 2015 at 18:25
8
  • 1
    Have you tried running mcc from the dos shell. May be forcing for $MATLABROOT$\bin\win32\mcc.exe and for expected compopts.x32.bat file with -f option. When compiling for both arch from same machine, matlab overwrites same compopts.bat (letting mbuild -setup create it for me) ... so i ended up forcing everything in my deploying scripts ... well here you say you're using two separate machines :( ... Commented Feb 12, 2015 at 20:05
  • 1
    On compilation PC I have both x64 and x32 versions of matlab so depending on which arch I want to build I either force scripts to point to ~\win32\mcc.exe or ~\win64\mcc.exe. For compopts.bat file, I created one with matlab x64 (mbuild -setup => renamed to compopts.x64.bat) and one with matlab x32 (mbuild -setup => renamed to compopts.x64.bat). I then again force correct one on mcc command line with the -f option (If not specified mcc.exe uses last generated compopts.bat [and as matlab x64/x32 generate this file on same disk location it can be the wrong one]) Commented Feb 13, 2015 at 0:27
  • 1
    Typo: For x32 should read renamed to compopts.x32.bat of course Commented Feb 13, 2015 at 0:37
  • 1
    For x32 I use lcc as compiler, and for x32 I use VS2012. I Would have like to use lcc in both cases (to avoid having to deploy VC redistributables), but unfortunately matlab does not provide for lcc in x64 mode (R2013b for me). Commented Feb 13, 2015 at 0:54
  • 1
    Great... Yes for x64 I use VS2012, very annoying ... so don't forget to deploy redistributables that correspond to your version of VS within the installer (This avoids long debug with customers saying The specified module could not be found) Commented Feb 16, 2015 at 17:21

1 Answer 1

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

  1. Install Matlab x32 and x64 on your machine
  2. Run Matlab x32 and setup compiler options typing msbuild -setup

    • This will generate a compopts.bat file in ~user\AppData\Roaming\MathWorks\MATLAB\R2013b (path may differ upon your version)
    • Rename this file to compopts.x32.bat (see later)
  3. Run Matlab x64 and setup compiler options typing msbuild -setup

    • This will generate a compopts.bat file in ~user\AppData\Roaming\MathWorks\MATLAB\R2013b (!!Overwrites x32!!)
    • Rename this file to compopts.x64.bat (To workaround file overwrite)

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 ... 
answered Feb 17, 2015 at 6:41
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.