1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

LovyanGFXAdvent Calendar 2022

Day 12

LovyanGFX for PC をLinuxで試す(clang利用)

Last updated at Posted at 2022-12-17

LovyanGFXのPC用シミュレータをLinuxで動かす手順は2日目に紹介されていますが、clangをインストールしたらあっさりと動いたので手順のメモを残しておきます。

2日目の記事ではg++でコンパイルをしていますが、clangでコンパイルするので以下のドキュメントからclangをインストールします。

自分は ubuntu 22.04 を利用しているので、↓を /etc/apt/sources.list に書き込んで sudo apt update を実行します。

# 15
deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main
deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main

updateしたらclang-15をインストールします。

$ sudo apt install clang-15

インストールしたら、cloneしたLovyanGFXのフォルダに移動します。

$ cd LovyanGFX/examples_for_PC/CMake_SDL

下記内容で clang-cmakeinit.cmake ファイルを作成して、

$ cat clang-cmakeinit.cmake 
set(CMAKE_C_COMPILER "/usr/bin/clang-15" CACHE string "clang compiler" FORCE)
set(CMAKE_CXX_COMPILER "/usr/bin/clang++-15" CACHE string "clang++ compiler" FORCE)

cmakeコマンドを実行してmakefileを作成します。

$ cmake -C clang-cmakeinit.cmake .
loading initial cache file clang-cmakeinit.cmake
CMake Warning (dev) at clang-cmakeinit.cmake:1 (set):
  implicitly converting 'string' to 'STRING' type.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at clang-cmakeinit.cmake:2 (set):
  implicitly converting 'string' to 'STRING' type.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/bin/clang-15
CMAKE_CXX_COMPILER= /usr/bin/clang++-15

-- The C compiler identification is Clang 15.0.6
-- The CXX compiler identification is Clang 15.0.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang-15 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++-15 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL

makeコマンドが作成されたらmakeコマンドを実行します。
終了するとバイナリが生成されます。

$ make
[  4%] Building C object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/Fonts/IPA/lgfx_font_japan.c.o
[  9%] Building C object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/Fonts/efont/lgfx_efont_cn.c.o
[ 13%] Building C object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/Fonts/efont/lgfx_efont_ja.c.o
[ 18%] Building C object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/Fonts/efont/lgfx_efont_kr.c.o
[ 22%] Building C object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/Fonts/efont/lgfx_efont_tw.c.o
[ 27%] Building C object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/utility/lgfx_pngle.c.o
[ 31%] Building C object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/utility/lgfx_qoi.c.o
/work/mysketch/LovyanGFX/src/lgfx/utility/lgfx_qoi.c:335:44: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
    debug_printf( "Can't malloc %d bytes", writeBufferSize);
                                ~~         ^~~~~~~~~~~~~~~
                                %zu
/work/mysketch/LovyanGFX/src/lgfx/utility/lgfx_qoi.c:73:43: note: expanded from macro 'debug_printf'
#define debug_printf(...) fprintf(stderr, __VA_ARGS__)
                                          ^~~~~~~~~~~
1 warning generated.
[ 36%] Building C object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/utility/lgfx_qrcode.c.o
[ 40%] Building C object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/utility/lgfx_tjpgd.c.o
[ 45%] Building C object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/utility/miniz.c.o
[ 50%] Building CXX object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/v1/LGFXBase.cpp.o
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/LGFXBase.cpp:19:
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/LGFXBase.hpp:29:
/work/mysketch/LovyanGFX/src/lgfx/v1/misc/colortype.hpp:417:15: warning: constexpr constructor that does not initialize all members is a C++20 extension [-Wc++20-extensions]
    constexpr bgra8888_t(uint8_t r8, uint8_t g8, uint8_t b8) : r(r8), g(g8), b(b8) {}
              ^
/work/mysketch/LovyanGFX/src/lgfx/v1/misc/colortype.hpp:405:17: note: member not initialized by constructor
        uint8_t a;
                ^
1 warning generated.
[ 54%] Building CXX object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/v1/LGFX_Button.cpp.o
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/LGFX_Button.cpp:19:
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/LGFX_Button.hpp:20:
/work/mysketch/LovyanGFX/src/lgfx/v1/misc/colortype.hpp:417:15: warning: constexpr constructor that does not initialize all members is a C++20 extension [-Wc++20-extensions]
    constexpr bgra8888_t(uint8_t r8, uint8_t g8, uint8_t b8) : r(r8), g(g8), b(b8) {}
              ^
/work/mysketch/LovyanGFX/src/lgfx/v1/misc/colortype.hpp:405:17: note: member not initialized by constructor
        uint8_t a;
                ^
1 warning generated.
[ 59%] Building CXX object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/v1/LGFX_Sprite.cpp.o
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/LGFX_Sprite.cpp:19:
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/LGFX_Sprite.hpp:22:
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/LGFXBase.hpp:29:
/work/mysketch/LovyanGFX/src/lgfx/v1/misc/colortype.hpp:417:15: warning: constexpr constructor that does not initialize all members is a C++20 extension [-Wc++20-extensions]
    constexpr bgra8888_t(uint8_t r8, uint8_t g8, uint8_t b8) : r(r8), g(g8), b(b8) {}
              ^
/work/mysketch/LovyanGFX/src/lgfx/v1/misc/colortype.hpp:405:17: note: member not initialized by constructor
        uint8_t a;
                ^
1 warning generated.
[ 63%] Building CXX object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/v1/lgfx_fonts.cpp.o
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/lgfx_fonts.cpp:4:
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/misc/pixelcopy.hpp:22:
/work/mysketch/LovyanGFX/src/lgfx/v1/misc/colortype.hpp:417:15: warning: constexpr constructor that does not initialize all members is a C++20 extension [-Wc++20-extensions]
    constexpr bgra8888_t(uint8_t r8, uint8_t g8, uint8_t b8) : r(r8), g(g8), b(b8) {}
              ^
/work/mysketch/LovyanGFX/src/lgfx/v1/misc/colortype.hpp:405:17: note: member not initialized by constructor
        uint8_t a;
                ^
1 warning generated.
[ 68%] Building CXX object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/v1/misc/SpriteBuffer.cpp.o
[ 72%] Building CXX object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/v1/misc/pixelcopy.cpp.o
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/misc/pixelcopy.cpp:19:
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/misc/pixelcopy.hpp:22:
/work/mysketch/LovyanGFX/src/lgfx/v1/misc/colortype.hpp:417:15: warning: constexpr constructor that does not initialize all members is a C++20 extension [-Wc++20-extensions]
    constexpr bgra8888_t(uint8_t r8, uint8_t g8, uint8_t b8) : r(r8), g(g8), b(b8) {}
              ^
/work/mysketch/LovyanGFX/src/lgfx/v1/misc/colortype.hpp:405:17: note: member not initialized by constructor
        uint8_t a;
                ^
/work/mysketch/LovyanGFX/src/lgfx/v1/misc/pixelcopy.cpp:39:25: warning: field 'src_bits' is uninitialized when used here [-Wuninitialized]
    , src_mask  ( (1 << src_bits) - 1 )
                        ^
/work/mysketch/LovyanGFX/src/lgfx/v1/misc/pixelcopy.cpp:40:25: warning: field 'dst_bits' is uninitialized when used here [-Wuninitialized]
    , dst_mask  ( (1 << dst_bits) - 1 )
                        ^
3 warnings generated.
[ 77%] Building CXX object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/v1/panel/Panel_Device.cpp.o
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/panel/Panel_Device.cpp:18:
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/panel/Panel_Device.hpp:20:
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/panel/../Panel.hpp:30:
/work/mysketch/LovyanGFX/src/lgfx/v1/panel/../misc/colortype.hpp:417:15: warning: constexpr constructor that does not initialize all members is a C++20 extension [-Wc++20-extensions]
    constexpr bgra8888_t(uint8_t r8, uint8_t g8, uint8_t b8) : r(r8), g(g8), b(b8) {}
              ^
/work/mysketch/LovyanGFX/src/lgfx/v1/panel/../misc/colortype.hpp:405:17: note: member not initialized by constructor
        uint8_t a;
                ^
1 warning generated.
[ 81%] Building CXX object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/v1/platforms/sdl/Panel_sdl.cpp.o
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/platforms/sdl/Panel_sdl.cpp:23:
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/platforms/sdl/Panel_sdl.hpp:23:
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/platforms/sdl/../../panel/Panel_Device.hpp:20:
In file included from /work/mysketch/LovyanGFX/src/lgfx/v1/platforms/sdl/../../panel/../Panel.hpp:30:
/work/mysketch/LovyanGFX/src/lgfx/v1/platforms/sdl/../../panel/../misc/colortype.hpp:417:15: warning: constexpr constructor that does not initialize all members is a C++20 extension [-Wc++20-extensions]
    constexpr bgra8888_t(uint8_t r8, uint8_t g8, uint8_t b8) : r(r8), g(g8), b(b8) {}
              ^
/work/mysketch/LovyanGFX/src/lgfx/v1/platforms/sdl/../../panel/../misc/colortype.hpp:405:17: note: member not initialized by constructor
        uint8_t a;
                ^
1 warning generated.
[ 86%] Building CXX object CMakeFiles/LGFX_SDL.dir/work/mysketch/LovyanGFX/src/lgfx/v1/platforms/sdl/common.cpp.o
[ 90%] Building CXX object CMakeFiles/LGFX_SDL.dir/LGFX_SDL.cpp.o
In file included from /work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL/LGFX_SDL.cpp:4:
In file included from /work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL/../../../LovyanGFX/src/LovyanGFX.hpp:31:
In file included from /work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL/../../../LovyanGFX/src/lgfx/v1_init.hpp:25:
In file included from /work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL/../../../LovyanGFX/src/lgfx/v1/LGFXBase.hpp:29:
/work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL/../../../LovyanGFX/src/lgfx/v1/misc/colortype.hpp:417:15: warning: constexpr constructor that does not initialize all members is a C++20 extension [-Wc++20-extensions]
    constexpr bgra8888_t(uint8_t r8, uint8_t g8, uint8_t b8) : r(r8), g(g8), b(b8) {}
              ^
/work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL/../../../LovyanGFX/src/lgfx/v1/misc/colortype.hpp:405:17: note: member not initialized by constructor
        uint8_t a;
                ^
1 warning generated.
[ 95%] Building CXX object CMakeFiles/LGFX_SDL.dir/user_code.cpp.o
In file included from /work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL/user_code.cpp:9:
In file included from /work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL/../../../LovyanGFX/src/LovyanGFX.hpp:31:
In file included from /work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL/../../../LovyanGFX/src/lgfx/v1_init.hpp:25:
In file included from /work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL/../../../LovyanGFX/src/lgfx/v1/LGFXBase.hpp:29:
/work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL/../../../LovyanGFX/src/lgfx/v1/misc/colortype.hpp:417:15: warning: constexpr constructor that does not initialize all members is a C++20 extension [-Wc++20-extensions]
    constexpr bgra8888_t(uint8_t r8, uint8_t g8, uint8_t b8) : r(r8), g(g8), b(b8) {}
              ^
/work/mysketch/LovyanGFX/examples_for_PC/CMake_SDL/../../../LovyanGFX/src/lgfx/v1/misc/colortype.hpp:405:17: note: member not initialized by constructor
        uint8_t a;
                ^
1 warning generated.
[100%] Linking CXX executable LGFX_SDL
[100%] Built target LGFX_SDL

生成されたバイナリを実行すると、LovyanGFX for PCが実行されます。

$ ./LGFX_SDL

image.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?