はじめに
最近Crystalにハマってて、GUI系のライブラリを試そうとしていた時のこと。
libui.rcを試そうとしたんだけど、サンプル動かんやん。。。
libuiのバインディングらしいので、まずはlibui動かすところから始めるか。と思いlibuiのREADME読みながらビルドしようとしたらまさかのこれも失敗。。。
スター8000以上あんのにそんなことある?と思い検索するとlibuiのissueが複数ヒット。
だけど日本語の記事はまだ無いっぽいので書きました。
結果
結果だけ知りたい人のために先にビルドできた手順を記載。
CMakeLists.txt
のCMAKE_OSX_DEPLOYMENT_TARGET
を書き換えることでビルドできる。
-set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8" CACHE STRING "" FORCE)
+set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
試したこと
以下は色々試したけどダメだった記録です。
まずはREADMEに従ってビルドしてみる。
$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is AppleClang 10.0.0.10001145
-- The CXX compiler identification is AppleClang 10.0.0.10001145
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- broken
CMake Error at /usr/local/Cellar/cmake/3.13.4/share/cmake/Modules/CMakeTestCXXCompiler.cmake:45 (message):
The C++ compiler
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/kaishoya/workspace/github/libui/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_eb1c0/fast"
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_eb1c0.dir/build.make CMakeFiles/cmTC_eb1c0.dir/build
Building CXX object CMakeFiles/cmTC_eb1c0.dir/testCXXCompiler.cxx.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -mmacosx-version-min=10.8 -o CMakeFiles/cmTC_eb1c0.dir/testCXXCompiler.cxx.o -c /Users/kaishoya/workspace/github/libui/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
1 warning generated.
Linking CXX executable cmTC_eb1c0
/usr/local/Cellar/cmake/3.13.4/bin/cmake -E cmake_link_script CMakeFiles/cmTC_eb1c0.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -mmacosx-version-min=10.8 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_eb1c0.dir/testCXXCompiler.cxx.o -o cmTC_eb1c0
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_eb1c0] Error 1
make: *** [cmTC_eb1c0/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:35 (project)
-- Configuring incomplete, errors occurred!
See also "/Users/kaishoya/workspace/github/libui/build/CMakeFiles/CMakeOutput.log".
See also "/Users/kaishoya/workspace/github/libui/build/CMakeFiles/CMakeError.log".
いまいち読みづらいけどエラー出た。
lstdc++が見つからないのが原因っぽい。
issueを読んでみるとcmakeの3.14.0でfixedされたらしいので、Homebrewを使ってアップデートしてみる。
$ brew upgrade cmake
==> Upgrading 1 outdated package:
cmake 3.13.4 -> 3.14.0
cmakeのバージョンが3.14.0になったことを確認して再ビルド。
若干出力が変わったけど、エラーの内容は全く一緒。
$ cmake ..
-- The C compiler identification is AppleClang 10.0.0.10001145
-- The CXX compiler identification is AppleClang 10.0.0.10001145
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- broken
CMake Error at /usr/local/Cellar/cmake/3.14.0/share/cmake/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/kaishoya/workspace/github/libui/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_f8de2/fast
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_f8de2.dir/build.make CMakeFiles/cmTC_f8de2.dir/build
Building CXX object CMakeFiles/cmTC_f8de2.dir/testCXXCompiler.cxx.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -mmacosx-version-min=10.8 -o CMakeFiles/cmTC_f8de2.dir/testCXXCompiler.cxx.o -c /Users/kaishoya/workspace/github/libui/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
1 warning generated.
Linking CXX executable cmTC_f8de2
/usr/local/Cellar/cmake/3.14.0/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f8de2.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -mmacosx-version-min=10.8 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_f8de2.dir/testCXXCompiler.cxx.o -o cmTC_f8de2
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_f8de2] Error 1
make: *** [cmTC_f8de2/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:35 (project)
-- Configuring incomplete, errors occurred!
See also "/Users/kaishoya/workspace/github/libui/build/CMakeFiles/CMakeOutput.log".
See also "/Users/kaishoya/workspace/github/libui/build/CMakeFiles/CMakeError.log".
gccとmakeのバージョンが古いからかな?と思い、gccとmakeを最新にしてみる。
gccバージョンアップ
$ brew install gcc
$ ln -s /usr/local/bin/gcc-8 /usr/local/bin/gcc
$ ln -s /usr/local/bin/g++-8 /usr/local/bin/g++
makeバージョンアップ
http://ftp.gnu.org/gnu/make/からダウンロードして、解答したディレクトリにcdする。
現時点(2019/3/18)で最新の4.2を選択。
$ ./configure
$ make
$ sh build.sh
$ ./make install
やっぱりビルド失敗。
諦めて、issueに書いてあるCMakeLists.txt
のCMAKE_OSX_DEPLOYMENT_TARGET
を"10.9"
に書き換えてビルド。
-set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8" CACHE STRING "" FORCE)
+set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
これでやっとビルドできた。
てことでcmakeの問題はまだ解消されてないっぽい。