Perhaps, but it is very dirty: the whole mbuild / deploytool system is part of cr * p, in my opinion. The first problem with deploytool.bat is that although it has the -win32 option, it has no effect when deploytool is not called from the 32-bit installation directory. The second problem is that mbuild parameters are separated for 32-bit and 64-bit versions, so they must be specified manually, as well as incorrect compiler options.
Here are some things I did to compile both 32-bit and 64-bit from a 64-bit Windows machine with VS2010 installed.
- you need to install both 32-bit and 64-bit versions of matlab
- you will need to do everything from the command line
- you will never be able to edit your .prj files with deploytool ui, because it twists all the manual changes made manually. (well, actually this is useful, since now you can at least be able to store them in VCS)
- specify the correct compiler options by adding
<param.c.cpp.options.file>
to prj in the "Configuration" section (see below). - build by manully giving full path to deploytool.bat 32-bit installation
file config parameter in prj:
<deployment-project> <configuration ....> .... <param.c.cpp.options.file>${MATLAB_ROOT}\bin\win32\mbuildopts\msvc100compp.bat</param.c.cpp.options.file> ....
Please note that the output, etc. will be the same for the 32-bit and 64-bit versions. In practice, if you need to do this for several projects, it becomes completely unmanageable. So I have an msbuild script to make life easier: basically in the prj file I replace all platform-dependent (dir output, matlab root directory, location of the option files) macros, and then let msbuild copy prj and execute find / regex replace macros with values โโdepending on the platform. This allows you to use the same prj for both platforms.
Update
After several significant changes in our projects, we found that in the end, the hassle with mplab prj files is not worth it. Instead, we greatly simplified everything by calling mcc
directly and passing it to all the files belonging to the project. Here is the relevant msbuild code; some error checks are omitted for clarity:
<Target Name="BuildMatlabProject"> <PropertyGroup Condition="$(MlPlatform)=='x86'"> <MlMatlabBinDir>$(MlMatlabx86Dir)\bin\win32</MlMatlabBinDir> </PropertyGroup> <PropertyGroup Condition="$(MlPlatform)=='x64'"> <MlMatlabBinDir>$(MlMatlabx64Dir)\bin\win64</MlMatlabBinDir> </PropertyGroup> <ItemGroup> <MlMFiles Include="$(MlMatlabProjDir)\*.m"/> <MlMResources Include="$([System.IO.Directory]::GetDirectories("$(MlMatlabSrcDir)"))"/> </ItemGroup> <PropertyGroup> <MlMresourcseString Condition="@(MlMResources)!=''"> -a @(MlMResources, ' -a ')</MlMresourcseString> </PropertyGroup> <RemoveDir Directories="$(MlOutDir)" ContinueOnError="true"/> <MakeDir Directories="$(MlOutDir)"/> <Exec Command="$(MlMatlabBinDir)\mcc -W cpplib:$(MlOutputName)_$(MlPlatform) -T link:lib -d $(MlOutDir) -f $(MlMatlabBinDir)\mbuildopts\msvc100compp.bat -w enable:specified_file_mismatch -w enable:repeated_file -w enable:switch_ignored -w enable:missing_lib_sentinel -w enable:demo_license -v @(MlMFiles, ' ') $(MlMresourcseString)"/> </Target>
He needs the following properties:
- MlPlatform: x86 for building a 32-bit version, x64 for building a 64-bit version
- MlMatlabx86Dir: path to matlab 32bit install dir
- MlMatlabx64Dir: path to Matlab 64-bit dir installation
- MlMatlabProjDir: path to the 'project' file with m files to compile
- MlMatlabSrcDir: path with additional files m files
- MlOutDir: output directory
- MlOutputName: exit name
stijn
source share