Scoop環境でSDL2をビルドしてみた

何も考えずにビルドしようとしたら、エラーが出まくって面倒くさいことになったので、今後に備えてメモ

前提条件

shは
[powershell]
Scoop install busybox
[/powershell]
でインストール済み
gccは
[powershell]
Scoop install gcc
[/powershell]
でインストール済み

./configure

/bin/shが見つからないので(あるわけない。Windows環境だし)configureスクリプトが動かない。
多分他のライブラリもconfigureは無理だからcmakeがないとビルドは無理そう

cmake

[powershell]
Scoop install cmake make
[/powershell]
でcmakeとmakeをインストール
ここからsdl2.0の最新のtar.gzをダウンロード
[powershell]
tar xvfz SDL2-x.x.x.tar.gz
cd SDL2-x.x.x
mkdir build
cd build
[/powershell]
でソースコードを展開してビルドディレクトリを作成し移動。
ここでcmakeするわけだが、
[powershell]
cmake -G "MinGW Makefiles" ..
[/powershell]
だと

CMake Error at D:/Scoop/apps/cmake/3.12.0/share/cmake-3.12/Modules/CMakeMinGWFindMake.cmake:12 (message):
  sh.exe was found in your PATH, here:
  D:/Scoop/shims/sh.exe
  For MinGW make to work correctly sh.exe must NOT be in your path.
  Run cmake from a shell that does not have sh.exe in your PATH.
  If you want to use a UNIX shell, then use MSYS Makefiles.
Call Stack (most recent call first):
  CMakeLists.txt:6 (project)
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage

と出てcmake失敗。MSYS MakefilesでやれとあるからMSYS Makefilesで試してみたら

-- The C compiler identification is GNU 7.3.0
-- Check for working C compiler: D:/Scoop/apps/gcc/current/bin/gcc.exe
-- Check for working C compiler: D:/Scoop/apps/gcc/current/bin/gcc.exe -- broken
CMake Error at D:/Scoop/apps/cmake/3.12.0/share/cmake-3.12/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler
    "D:/Scoop/apps/gcc/current/bin/gcc.exe"
  is not able to compile a simple test program.
  It fails with the following output:
    Change Dir: sdl/SDL2-2.0.8/build/CMakeFiles/CMakeTmp
    Run Build Command:"D:/Scoop/shims/make.exe" "cmTC_f78a5/fast"
    D:/Scoop/apps/make/current/make -f CMakeFiles/cmTC_f78a5.dir/build.make CMakeFiles/cmTC_f78a5.dir/build
    make[1]: Entering directory 'sdl/SDL2-2.0.8/build/CMakeFiles/CMakeTmp'
    sh: /D/Scoop/apps/cmake/3.12.0/bin/cmake.exe: Permission denied
    make[1]: *** [CMakeFiles/cmTC_f78a5.dir/build.make:65: CMakeFiles/cmTC_f78a5.dir/testCCompiler.c.obj] Error 126
    make[1]: Leaving directory 'sdl/SDL2-2.0.8/build/CMakeFiles/CMakeTmp'
    make: *** [makefile:121: cmTC_f78a5/fast] Error 2
  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:6 (project)

と出てやはり失敗。
いろいろ探った結果
brew-like Scoop for Windowsここに

cmake -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND" ..

でやってみろとあったので、試したところcmake成功
makeしたらlibSDL2.dllとlibSDL2-static.aの両方ができてた。
ただし、このままだとC:\Program Files(x86)にインストールしようとするので、-DCMAKE_INSTALL_PREFIX=”D:\Scoop\lib”とか設定してインストール先を変えたほうが良さそう。
使うときは-DCMAKE_MODULE_PATH=”D:\Scoop\lib”で見つけてくれるっぽい。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です