Giter Club home page Giter Club logo

setup_mex's Introduction

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, focusing on macOS and Windows.

Note that MATLAB requires you to install a supported (C or Fortran) compiler along with Xcode (on macOS with Intel chips) or Microsoft Visual Studio (on Windows). This package is not a hacking tool to circumvent these requirements, but a tool to help MATLAB recognize your compiler after these requirements are satisfied.

As of April 2024, we do not support Fortran setup on macOS with silicon chips, because MathWorks requires the NAG Fortran compiler for such a setup, which is not available for free.

For Fortran, this package provides scripts (install_oneapi_macos.sh for macOS with Intel chips and install_oneapi_windows.bat for Windows) to help you install the Fortran compiler from Intel oneAPI, available free of charge. This is the compiler officially supported by MATLAB.

This package has been successfully tested on all recent releases of MATLAB under recent versions of Windows and macOS via GitHub Actions. Nevertheless, I will not be surprised if it does not work on your machine. In that case, 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 with Intel chips

  • C

    • Install Xcode with 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.

      -- If your MATLAB version is R2023b or below, then run

      install_oneapi_windows.bat 2023

      -- If your MATLAB version is R2024a or above, then 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.

setup_mex's People

Contributors

dependabot[bot] avatar zaikunzhang avatar

Stargazers

 avatar  avatar

Watchers

 avatar

setup_mex's Issues

mex with intel oneAPI on maxOS M2

(base) huijunli@office-Mac src % $MATLAB_ROOT/bin/mex xtimesy.F
使用 'Intel Fortran' 编译。
ld: warning: -undefined error is deprecated
ld: warning: -undefined error is deprecated
ld: warning: ignoring file '/private/var/folders/0d/dv0bsg010n570x9w4gdwhfcr0000gn/T/mex_10406043762116_26660/xtimesy.o': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/private/var/folders/0d/dv0bsg010n570x9w4gdwhfcr0000gn/T/mex_10406043762116_26660/fortran_mexapi_version.o': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/opt/intel/oneapi/compiler/2023.2.0/mac/compiler/lib/libifcore.dylib': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/opt/intel/oneapi/compiler/2023.2.0/mac/compiler/lib/libsvml.dylib': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/opt/intel/oneapi/compiler/2023.2.0/mac/compiler/lib/libimf.dylib': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/opt/intel/oneapi/compiler/2023.2.0/mac/compiler/lib/libintlc.dylib': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/opt/intel/oneapi/compiler/2023.2.0/mac/compiler/lib/libirc.dylib': found architecture 'x86_64', required architecture 'arm64'
ld: Undefined symbols:
mexfunction, referenced from:

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.