Skip to content

This package provides scripts that attempt to facilitate setting up the MATLAB MEX.

License

Notifications You must be signed in to change notification settings

romaintilhac/setup_mex

 
 

Repository files navigation

setup_mex

license Test MEX View setup_mex on File Exchange

What

This package provides scripts that attempt to facilitate setting up the MATLAB MEX on macOS or Windows. For Fortran, it will install (automatically) the Fortran compiler from Intel oneAPI, available free of charge. The setup on Linux is trivial and Linuxers should be capable of handling it half asleep.

Whether the method here works or not, it depends on the configuration of your system and your MATLAB. Trying will not hurt. In case it fails, you need to consult a local MATLAB expert or the technical support of MathWorks about "how to set up MEX".

How

Before starting, clone this repository. Then do the following according to your system (macOS or Windows) and your need (C or Fortran).

macOS

  • C

    • Install Xcode with Clang

      (After installing Xcode, type in Terminal: xcodebuild -find make xcodebuild -find gcc xcodebuild -find g++ xcodebuild -find clang xcodebuild -find clang++)

    • In MATLAB, change the directory to the folder of the repository, run

    try_mex_setup('c')
  • Fortran

    • Install Xcode with Clang
    • In terminal, change the directory to the folder of the repository, run
    sudo bash install_oneapi_macos.sh
    • In MATLAB, change the directory to the folder of the repository, run
    try_mex_setup('fortran')

Windows

  • C

    • Install Microsoft Visual Studio with the "Desktop development with C++" workload
    • In MATLAB, change the directory to the folder of the repository, run
    try_mex_setup('c')
  • Fortran

    • Install Microsoft Visual Studio with the "Desktop development with C++" workload
    • In cmd (not PowerShell), change the directory to the folder of the repository, run
    install_oneapi_windows.bat
    • In MATLAB, change the directory to the folder of the repository, run
    try_mex_setup('fortran')

Remarks

  1. Always adopt the default options (e.g., installation directory) when installing Xcode (on macOS) or Microsoft Visual Studio (on Windows). Otherwise, MATLAB may not be able to locate them.

  2. Choose the version of Xcode or Microsoft Visual Studio according to that of your MATLAB, following the official documentation of MathWorks. The latest version does not necessarily work.

About

This package provides scripts that attempt to facilitate setting up the MATLAB MEX.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • MATLAB 71.6%
  • Batchfile 14.9%
  • Shell 13.5%