Search code examples
sseapple-m1vector-class-library

How to compile a project which requires SSE2 on MacBook with M1 chip?


I need to install a software which requires SSE2 on my macbook air with M1 chip (os Monterey).

When I am trying to compile the project I receive the following error:

/libRootFftwWrapper/vectorclass/vectorclass.h:38:4: error: Please compile for the SSE2 instruction set or higher
  #error Please compile for the SSE2 instruction set or higher
   ^

and the error message links to the following lines in the code:

#include "instrset.h"        // Select supported instruction set

#if INSTRSET < 2             // SSE2 required
  #error Please compile for the SSE2 instruction set or higher
#else

I understand that only Intel chips equipped with SSE2, but is there any kind of a translator which can help me to build this project?

Update: problem is solved. Solution is in the answer section.


Solution

  • I managed to compile the project by using rosetta 2, as it was suggested in the comments below. To install rosetta I used the following command:

    $ softwareupdate --install-rosetta
    

    Then I installed Homebrew, clang and cmake for x86_64 arch by using:

    $ arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    $ arch -x86_64 /usr/local/bin/brew install llvm
    $ arch -x86_64 /usr/local/bin/brew install cmake
    

    I also had to re-tap Homebrew by using:

    $ rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core"
    $ arch -x86_64 /usr/local/bin/brew tap homebrew/core 
    

    as it was suggested by brew doctor.

    finally, the project was compiled after removing previously generated CMakeCache:

    $ make clean
    $ arch -x86_64 /usr/local/bin/cmake build_dir 
    $ make 
    $ make install