← 블로그 목록

[과제] 1주차) 프로젝트 작업환경 구성 노수연

@numkite
  • #과제

환경

OS: MacOS CPU: Apple M4 Pro Package Manager: Homebrew

빌드 도구

빌드에 meson 과 ninja 사용

brew install meson ninja

git 클론

mkdir thorvg-project
cd thorvg-project
git clone https://github.com/thorvg/thorvg.git
git clone https://github.com/thorvg/thorvg.example.git

빌드

thorvg 빌드

cd throng
meson setup builddir

meson options 활성화 위해 meson_options.txt 참고해 옵셥들 활성화하려 함

meson setup builddir \
  -Dengines=all \
  -Dpartial=true \
  -Dloaders=all \
  -Dsavers=all \
  -Dthreads=true \
  -Dsimd=true \
  -Dbindings=capi \
  -Dtools=all \
  -Dtests=true \
  -Dlog=true \
  -Dfile=true \
  -Dextra=lottie_exp,openmp

하지만 위 코드 실행 시 아래와 같은 에러 발생

Found pkg-config: NO Did not find CMake ‘cmake’ Found CMake: NO Run-time dependency wgpu_native found: NO (tried framework)

해결 위해 dependency 도구 설치

brew install pkg-config
brew install libomp libpng webp jpeg-turbo wgpu-native sdl2

pkg-config로 설치된 경로는 잘 잡히지만 wgpu_native 라이브러리를 찾지 못해 빌드 멈춤 발생 wgpu-native 라이브러리 및 .pc 파일 생성

mkdir -p "$HOME/.local/lib/pkgconfig"
WGPU_PREFIX="$(brew --prefix wgpu-native)"
WGPU_VERSION="$(brew list --versions wgpu-native | awk '{print $2}')"

cat > "$HOME/.local/lib/pkgconfig/wgpu_native.pc" <<EOF
prefix=$WGPU_PREFIX
includedir=\${prefix}/include
libdir=\${prefix}/lib
shimdir=$HOME/.local/include
Name: wgpu_native
Description: Native WebGPU implementation based on wgpu-core
Version: $WGPU_VERSION
Cflags: -I\${shimdir} -I\${includedir}
Libs: -L\${libdir} -lwgpu_native
EOF

cp "$HOME/.local/lib/pkgconfig/wgpu_native.pc" "$HOME/.local/lib/pkgconfig/wgpu-native.pc"
export PKG_CONFIG_PATH="$HOME/.local/lib/pkgconfig:/opt/homebrew/lib/pkgconfig:$PKG_CONFIG_PATH"

Meson이 wgpu-native 헤더 파일과 라이브러리 찾을 수 있도록 환경 변수 및 빌드 옵션 수정 및 빌드 실행

meson setup builddir \
  -Dengines=all \
  -Dpartial=true \
  -Dloaders=all \
  -Dsavers=all \
  -Dthreads=true \
  -Dsimd=true \
  -Dbindings=capi \
  -Dtools=all \
  -Dtests=true \
  -Dlog=true \
  -Dfile=true \
  -Dextra=lottie_exp,openmp \
  -Db_lundef=false \
  -Dcpp_args="-I$(brew --prefix wgpu-native)/include" \
  -Dcpp_link_args="-L$(brew --prefix wgpu-native)/lib"
ninja -C builddir
cd ..

thorvg.example 빌드

cd thorvg.example
meson setup builddir
ninja -C builddir
cd ..

예제 실행 결과

./thorvg.example/builddir/src/Animation gl

https://github.com/user-attachments/assets/0a10ed6d-18aa-49c4-9177-a527bce29583

./thorvg.example/builddir/src/Lottie gl

https://github.com/user-attachments/assets/bc49ec59-e03e-45ec-ab6b-349070f335b9

댓글

Discussion 원문