-
Notifications
You must be signed in to change notification settings - Fork 0
Apple Silicon Mac에서 빌드
Sejin Park edited this page Jan 17, 2023
·
3 revisions
# Install Homebrew at /usr/local (for Intel Rosetta 2)
$ arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
.zshrc에 아래 환경변수 추가
if [[ $(arch) == "arm64" ]]; then
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/local/sbin:$PATH"
else
export PATH="/usr/local/bin:/usr/local/sbin:/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
fi
# arm64 -> x86
$ arch -arch x86_64 /bin/zsh
# x86 -> arm64
$ arch -arch arm64e /bin/zsh
$ arch -arch x86_64 /bin/zsh
$ /usr/local/bin/brew install llvm
CMakeLists.txt에 아래 설정 추가
SET(CMAKE_CXX_COMPILER /usr/local/Cellar/llvm/15.0.7/bin/clang++)
프로젝트에 필요한 x86용 라이브러리 설치
./vcpkg install glm:x64-osx sdl2:x64-osx catch2:x64-osx spdlog:x64-osx
$ cmake -B out -S . -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake
$ cmake --build out
3번의 x86용 clang 설치 과정과 4번의 CMakeLists.txt 설정 추가 과정 없이 arch -arch x86_64 /bin/zsh 로 x86 환경으로 변경 후 바로 빌드해도 빌드가 되는 것 확인.
그렇지만 일단 위의 방법을 권장.
- http://seyong.me/macos/run-x86-terminal-app-with-apple-silicon
- https://velog.io/@bokyungkim/M1-%EB%A7%A5%EC%97%90%EC%84%9C-x86-%ED%84%B0%EB%AF%B8%EB%84%90-%EB%AA%85%EB%A0%B9-%EC%8B%A4%ED%96%89%ED%95%98%EA%B8%B0-symbols-not-found-for-architecture-arm64-%EC%97%90%EB%9F%AC
- https://xo.dev/m1-terminal-environment-setup/
- https://stackoverflow.com/questions/67386941/using-x86-libraries-and-openmp-on-macos-arm64-architecture