Need to pre-install MATLAB if compiling MATLAB mex file is required; Typing command mex -help
(or mex.bat -help
on Windows) in a terminal window (cmd
on windows) must finds the command, otherwise, one needs to add the path to mex command to your PATH environment variable.
Similarly, one needs to install Octave if compiling GNU Octave mex file is required; Typing command mkoctfile
in a terminal should print a short usage info; otherwise, you must install octave and add path to that includes the mkoctfile
command.
The requirements for compiling MCXCL are nearly identical to those for MMC because both of them use OpenCL by default.
Tested on Ubuntu Linux (various LTS)
sudo apt-get install gcc git ocl-icd-libopencl1 opencl-headers ocl-icd-opencl-dev liboctave-dev wget https://github.com/fangq/mmc/archive/v2020.tar.gz tar zxvf v2020.tar.gz && cd mmc-2020/src make mex make clean make oct make clean make
Tested on Windows 10 20H2; OpenCL.dll
must exist under C:\Windows\System32
, which should have been installed by the graphics driver already.
The goal here is to compile all units by the x86_64-w64-mingw32-gcc/g++
commands, both inside and outside MATLAB/Octave. This ensures that the output .obj/.o files can be linked without needing cygwin1.dll
or msys-2.0.dll
; the mv/ln -s x86_64-w64-mingw32-g*
commands below seem to be invasive, but it allows the makefile to use x86_64-w64-mingw32-gcc
compiler uniformly, otherwise, the default gcc on cygwin64 will use x86_64-pc-cygwin-gcc
and that for MSYS2 is x86_64-pc-msys-gcc
; these adds cygwin1.dll/msys-2.0.dll as dependency, respectively. If mv/ln is not perfered, one should attach CC=x86_64-w64-mingw32-gcc.exe CXX=x86_64-w64-mingw32-g++.exe AR=x86_64-w64-mingw32-g++.exe
to all make commands
Here are the detailed steps to build mmc/mcxcl mex/exe from a freshly installed Windows
setup-x86_64.exe
, select and install the below packages
octave-devel nano xxd zip unzip mingw64-x86-64-gcc-g++ make mingw64-x86_64-zlib zlib-devel upx
cd /usr/bin/ mv cc cc_old mv g++ g++_old ln -s x86_64-w64-mingw32-gcc.exe cc ln -s x86_64-w64-mingw32-g++.exe g++ ln -s nano pico
pacman -Syu pacman -Sy base-devel gcc git mingw-w64-x86_64-gcc mingw-w64-x86_64-opencl-headers zlib-devel cd c:/msys64/mingw64/lib ln -s libz.a liblibz.a
nano ~/.bashrc
, create if does not exist, and add to the end export MW_MINGW64_LOC="C:\msys64\mingw64"
env
in the start-menu, then click Edit System Environment variable, and select Environment Variable, double-click on the Path
variable, either under the user- or system section, click New
, and add full path to matlab so that mex.bat
command is callable from cmd
command line.
setenv('MW_MINGW64_LOC','C:\msys64\mingw64');
then type mex -setup C
and select MinGW C compiler for C; then type mex -setup C++
and do the same; if you want to use mingw c++ for all mex files, run edit(fullfile(userpath,'startup.m'))
and type the above commands to the startup.m file so that it runs automatically everytime
mmclab/{mmc.mexw64, mmc.mex}
and src/bin/mmc.exe
sequentially
wget https://github.com/fangq/mmc/archive/v2020.tar.gz tar zxvf v2020.tar.gz && cd mmc-2020/src make mex make clean make oct make clean make
cd mmc/deploy
, and run ./buildmmc.sh
, this should download the latest version of mmc from github, and build all 3 packages under ~/space/autobuild/nightly/mmc/mmc*-nightly-build.zip
C:\cygwin64\bin\bash.exe
and argument to -l -c "/cygdrive/c/path/to/mmc/deploy/buildmcxcl.sh
, set "Run whether user is logged on or not" in the General Tab.