codewitch-honey-crisis / gfx

GFX is a device independent graphics library primarily intended for IoT MCUs but not limited to that.
https://honeythecodewitch.com/gfx
MIT License
108 stars 10 forks source link

Unable to build native on macOS #34

Closed cmumford closed 1 month ago

cmumford commented 1 month ago

I'm guessing that building the library to run natively on macOS (Apple Silicon) may be unsupported. When I try this I get many errors, the first of which is:

 *  Executing task: platformio run --environment native 

Processing native (platform: native)
-----------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 9 compatible libraries
Scanning dependencies...
Dependency Graph
|-- htcw_gfx @ 1.679.0
|-- usb_util
Building in release mode
Compiling .pio/build/native/src/main_native.o
Compiling .pio/build/native/libdf3/htcw_io/io_stream.o
Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_drawing.o
Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_encoding.o
Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_font.o
Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_image.o
Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_math.o
Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_open_font.o
Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_palette.o
Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_pixel.o
Archiving .pio/build/native/libdf3/libhtcw_io.a
Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_svg_builder.o
.pio/libdeps/native/htcw_gfx/src/gfx_encoding.cpp:163:15: warning: result of comparison of constant 128 with expression of type 'char' is always true [-Wtautological-constant-out-of-range-compare]
        if (c < 0x80) {
            ~ ^ ~~~~
Indexing .pio/build/native/libdf3/libhtcw_io.a
1 warning generated.
.pio/libdeps/native/htcw_gfx/src/gfx_font.cpp:172:38: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
            out_font->m_style.italic = 1;
                                     ^ ~
.pio/libdeps/native/htcw_gfx/src/gfx_font.cpp:175:41: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
            out_font->m_style.underline = 1;
                                        ^ ~
.pio/libdeps/native/htcw_gfx/src/gfx_font.cpp:178:41: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
            out_font->m_style.strikeout = 1;
                                        ^ ~
In file included from .pio/libdeps/native/htcw_gfx/src/gfx_drawing.cpp:1:
In file included from .pio/libdeps/native/htcw_gfx/include/gfx_drawing.hpp:7:
In file included from .pio/libdeps/native/htcw_gfx/include/gfx_bitmap.hpp:5:
.pio/libdeps/native/htcw_gfx/include/gfx_pixel.hpp:429:56: error: no member named 'channel_index_by_name' in \
'gfx::pixel<gfx::channel_traits<gfx::channel_name::R, 16>, gfx::channel_traits<gfx::channel_name::G, 16>,
gfx::channel_traits<gfx::channel_name::B, 16>, gfx::channel_traits<gfx::channel_name::A, 16, 0, 65535, 65535>>'
            using chidx = typename PixelType::template channel_index_by_name<ChannelName>;

The reason I'd like to do this build is so that I can write a test program that outputs many test images for easy viewing. If I'm missing a preprocessor directive please advise.

Here is my platformio.ini file:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[common]
platform = espressif32
framework = espidf
build_unflags=-std=gnu++11
build_flags=-std=gnu++23
; htcw_gfx uses variable length arrays.
; It also fails on -Wshadow - which would be nice to fix.
build_src_flags = -Wall -Wextra -pedantic -pedantic-errors -Werror -Wno-vla
lib_deps = codewitch-honey-crisis/htcw_gfx@^1.679
boards_dir = boards
; If monitor_filters is set to `esp32_exception_decoder` then monitor_raw
; must be set to `no`.
monitor_raw = no
monitor_filters = esp32_exception_decoder

[env:lilygo-t-display-s3]
platform = ${common.platform}
board = lilygo-t-display-s3
framework = ${common.framework}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags}
build_src_flags = ${common.build_src_flags}
lib_deps = ${common.lib_deps}
monitor_raw = ${common.monitor_raw}
monitor_filters = ${common.monitor_filters}

[env:esp32-usb-cable-tester]
platform = ${common.platform}
board = esp32-usb-cable-tester
framework = ${common.framework}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags}
build_src_flags = ${common.build_src_flags}
lib_deps = ${common.lib_deps}
monitor_raw = ${common.monitor_raw}
monitor_filters = ${common.monitor_filters}
monitor_speed = 115200

[env:native]
platform = native
build_src_filter =
    -<*.cc>
    -<*.h>
    +<main_native.cc>
build_unflags=-std=gnu++11
# Defining UNITY_EXCLUDE_FLOAT to fix odd compile error. This is supposedly
# fixed in unity, but not yet in the PlatformIO version of unity.
# See discussion in https://github.com/ThrowTheSwitch/Unity/issues/660
build_flags=-std=gnu++2b -DGFX_LITTLE_ENDIAN -DUNITY_EXCLUDE_FLOAT
lib_deps = ${common.lib_deps}

Thx for making this library!

codewitch-honey-crisis commented 1 month ago

Offhand I don't have a mac to make this go. I'm not sure why it's not finding channel index by _ name.

I'll look into it but I can't promise anything. 🙁


From: Chris Mumford @.> Sent: Wednesday, July 17, 2024 1:43 AM To: codewitch-honey-crisis/gfx @.> Cc: Subscribed @.***> Subject: [codewitch-honey-crisis/gfx] Unable to build native on macOS (Issue #34)

I'm guessing that building the library to run natively on macOS (Apple Silicon) may be unsupported. When I try this I get many errors, the first of which is:

Processing native (platform: native)

Verbose mode can be enabled via -v, --verbose option LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf LDF Modes: Finder ~ chain, Compatibility ~ soft Found 9 compatible libraries Scanning dependencies... Dependency Graph |-- htcw_gfx @ 1.679.0 |-- usb_util Building in release mode Compiling .pio/build/native/src/main_native.o Compiling .pio/build/native/libdf3/htcw_io/io_stream.o Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_drawing.o Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_encoding.o Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_font.o Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_image.o Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_math.o Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_open_font.o Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_palette.o Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_pixel.o Archiving .pio/build/native/libdf3/libhtcw_io.a Compiling .pio/build/native/lib1a5/htcw_gfx/gfx_svg_builder.o .pio/libdeps/native/htcw_gfx/src/gfx_encoding.cpp:163:15: warning: result of comparison of constant 128 with expression of type 'char' is always true [-Wtautological-constant-out-of-range-compare] if (c < 0x80) { ~ ^ ~~~~ Indexing .pio/build/native/libdf3/libhtcw_io.a 1 warning generated. .pio/libdeps/native/htcw_gfx/src/gfx_font.cpp:172:38: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] out_font->m_style.italic = 1; ^ ~ .pio/libdeps/native/htcw_gfx/src/gfx_font.cpp:175:41: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] out_font->m_style.underline = 1; ^ ~ .pio/libdeps/native/htcw_gfx/src/gfx_font.cpp:178:41: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] out_font->m_style.strikeout = 1; ^ ~ In file included from .pio/libdeps/native/htcw_gfx/src/gfx_drawing.cpp:1: In file included from .pio/libdeps/native/htcw_gfx/include/gfx_drawing.hpp:7: In file included from .pio/libdeps/native/htcw_gfx/include/gfx_bitmap.hpp:5: .pio/libdeps/native/htcw_gfx/include/gfx_pixel.hpp:429:56: error: no member named 'channel_index_by_name' in \ 'gfx::pixel<gfx::channel_traits<gfx::channel_name::R, 16>, gfx::channel_traits<gfx::channel_name::G, 16>, gfx::channel_traits<gfx::channel_name::B, 16>, gfx::channel_traits<gfx::channel_name::A, 16, 0, 65535, 65535>>' using chidx = typename PixelType::template channel_index_by_name;

The reason I'd like to do this build is so that I can write a test program that outputs many test images for easy viewing. If I'm missing a preprocessor directive please advise.

Here is my platformio.ini file:

; PlatformIO Project Configuration File ; ; Build options: build flags, source filter ; Upload options: custom upload port, speed and extra flags ; Library options: dependencies, extra library storages ; Advanced options: extra scripting ; ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html

[common] platform = espressif32 framework = espidf build_unflags=-std=gnu++11 build_flags=-std=gnu++23 ; htcw_gfx uses variable length arrays. ; It also fails on -Wshadow - which would be nice to fix. build_src_flags = -Wall -Wextra -pedantic -pedantic-errors -Werror -Wno-vla lib_deps = codewitch-honey-crisis/htcw_gfx@^1.679 boards_dir = boards ; If monitor_filters is set to esp32_exception_decoder then monitor_raw ; must be set to no. monitor_raw = no monitor_filters = esp32_exception_decoder

[env:lilygo-t-display-s3] platform = ${common.platform} board = lilygo-t-display-s3 framework = ${common.framework} build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} build_src_flags = ${common.build_src_flags} lib_deps = ${common.lib_deps} monitor_raw = ${common.monitor_raw} monitor_filters = ${common.monitor_filters}

[env:esp32-usb-cable-tester] platform = ${common.platform} board = esp32-usb-cable-tester framework = ${common.framework} build_unflags = ${common.build_unflags} build_flags = ${common.build_flags} build_src_flags = ${common.build_src_flags} lib_deps = ${common.lib_deps} monitor_raw = ${common.monitor_raw} monitor_filters = ${common.monitor_filters} monitor_speed = 115200

[env:native] platform = native build_src_filter = -<.cc> -<.h> + build_unflags=-std=gnu++11

Defining UNITY_EXCLUDE_FLOAT to fix odd compile error. This is supposedly

fixed in unity, but not yet in the PlatformIO version of unity.

See discussion in https://github.com/ThrowTheSwitch/Unity/issues/660

build_flags=-std=gnu++2b -DGFX_LITTLE_ENDIAN -DUNITY_EXCLUDE_FLOAT lib_deps = ${common.lib_deps}

Thx for making this library!

— Reply to this email directly, view it on GitHubhttps://github.com/codewitch-honey-crisis/gfx/issues/34, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AD5ICVOZYAMOWT5FNYUAPJDZMYVCFAVCNFSM6AAAAABLAEXALCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQYTGMBSGI2TGNQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

codewitch-honey-crisis commented 1 month ago

On second thought, if it's possible downgrade gnu++23 to gnu++17 It could be that there are breaking standards changes

cmumford commented 1 month ago

-std=gnu++17, -std=c++17, -std=gnu++20 still have the same compile error. I also tried -std=c++2b instead of -std=gnu++2b - also with the same error. Available options are:

note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
note: use 'gnu++98' or 'gnu++03' for 'ISO C++ 1998 with amendments and GNU extensions' standard
note: use 'c++11' for 'ISO C++ 2011 with amendments' standard
note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard
note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' standard
note: use 'c++20' for 'ISO C++ 2020 DIS' standard
note: use 'gnu++20' for 'ISO C++ 2020 DIS with GNU extensions' standard
note: use 'c++2b' for 'Working draft for ISO C++ 2023 DIS' standard
note: use 'gnu++2b' for 'Working draft for ISO C++ 2023 DIS with GNU extensions' standard
codewitch-honey-crisis commented 1 month ago

I'm surprised at these compile errors and stumped by them. I'm not sure why apple's compiler would be so different. This compiles on PCs, MSVC, GCC, zephyr, CubeMX, MCUXpresso. Figures apple wouldn't work I guess, since I don't have one. Sorry.

codewitch-honey-crisis commented 1 month ago

you have a bunch of build flags like pedantic-errors. Remove that.

cmumford commented 1 month ago

The builds I did for the c++17/20/2b above were without those build flags. If I get motivated I may try to use clang instead of gcc as per https://github.com/platformio/platform-native/issues/22. You won't hurt my feelings if you close this as out of scope/etc. I'll comment here if I learn anything else.

codewitch-honey-crisis commented 1 month ago

I will close it only because I can't help with this. If I ever get access to a mac for this I'll definitely look into it. It's just, me and Apple have irreconcilable differences that prevent me from buying one.

cmumford commented 1 month ago

I figured it out. I had build_unflags=-std=gnu++11, but your platformio.ini uses -std=gnu++14, so my build effectively became -std=gnu++14 -std=gnu++2b - maybe the first one wins in gcc? Thx for your help @codewitch-honey-crisis.

codewitch-honey-crisis commented 1 month ago

Awesome. I'm so glad you fixed it. It should work with C++14, but I have made optimizations with 17 and it's best to use that. The platformio.ini may have been 14 because for a long time the toolchains were using really old compilers on windows. 17 may not have been supported at one point. Also I changed from std to gnu and probably forgot to update that setting. Thanks for catching that.