Search code examples
matlabmex

Is it possible to have a mexopts.bat that links both 32 AND 64bit compilers?


I have Matlab 2010b and Microsoft VS2010.

For project related reasons I need to use alternatively the 32 and 64 bit version of Matlab.

I currently have two mexopts.bat files that I rename depending on the Matlab version I use to correctly link to the relevant compiler.

Is there a way to have a single file with links to both compilers and have Matlab automatically pick up the relevant one?


Solution

  • Thanks to Peter's comment, I investigated the command line options.

    An automatic way of doing what I need is:

    version = mexext;
    
    if (version(5) == '3') % this is 32bit
    
        % include 32bit version code
    
    elseif (version(5) == '6') % this is 64bit
    
        % include 64bit version code
    
    else
    
        % deal with problems (should never occour)
    
    end
    

    the mex command(s) will have to include the option -f $full_path_to_correct_mexopts.bat