cpp-gui-template-sdl2 icon indicating copy to clipboard operation
cpp-gui-template-sdl2 copied to clipboard

[Help Needed]: ImGui `AddFont` assertion failure when running SDL2 template

Open PerHac13 opened this issue 4 months ago • 5 comments

Description I’m trying to set up ImGui with SDL2 using this template. The build completes successfully, but when I run the app, it crashes with an assertion error from ImGui.


Steps to Reproduce

  1. Clone the repository.

  2. Build using the following commands:

    cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -B build/debug
    cmake --build build/debug
    
  3. Run:

    ./build/debug/src/app/App
    
  4. Observe the crash.

Note: A window briefly appears without any ImGui components before the application crashes. Running from WSL2 Ubuntu


Actual Behavior

[18:11:02] APP(debug): Current SDL_Renderer: opengl
[18:11:02] APP(debug): User config path: /path/.local/share/com.mycompany/BasicGuiProjectSetup/
App: /mypath/cpp-gui-template-sdl2/build/debug/_deps/imgui-src/imgui_draw.cpp:2535: ImFont* ImFontAtlas::AddFont(const ImFontConfig*): Assertion `font_cfg->SizePixels > 0.0f && "Is ImFontConfig struct correctly initialized?"' failed.
Aborted (core dumped)

Expected Behavior The application should run without crashing and display the default GUI.


Environment

  • OS:

    • Windows 11 (base)
    • Ubuntu 22.04 in WSL2 (running here)
  • Compiler: GCC 13.3.0

  • Build System: Ninja + CMake

  • CMake Version: 3.28.3


Additional Query

  • What is profile.json and why is it being saved to this path?

    User config path: /path/.local/share/com.mycompany/BasicGuiProjectSetup/
    

    Do I need to set up something for it manually?


Additional Context I’m new to setting up ImGui with SDL2. I chose this template because the documentation is great, but I still can’t figure out how to resolve the crash. Any help would be greatly appreciated!

Thanks

PerHac13 avatar Aug 12 '25 13:08 PerHac13

Hey thanks for reporting the issue! I imagine it could relate to the font file not being found. I can have a look soon and test on Ubuntu when I got a VM running. The “profile.json” is profiler data as described here: https://github.com/MartinHelmut/cpp-gui-template-sdl2/blob/main/docs/Profiling.md I should update the documentation with this specific file name as it is the default currently.

MartinHelmut avatar Aug 15 '25 16:08 MartinHelmut

Thanks for the response looking forward to using this template

PerHac13 avatar Aug 16 '25 08:08 PerHac13

Alright. I could not replicate the issue but I added a check to the code, and, if not found, a warning (#30). If this lets you start the application without crash you probably get a warning in the console. If it starts you can also check the "Debug" window (In the app menu View -> Debug) and see under what path the application was looking for a font.

MartinHelmut avatar Aug 16 '25 18:08 MartinHelmut

First i want to thanks, now i am able to build the app in release mode. its working totally fine. it showing application ui.

still facing issue in building debug mode

[1/13] Building CXX object src/core/CMakeFiles/Core.dir/Core/Log.cpp.o
FAILED: src/core/CMakeFiles/Core.dir/Core/Log.cpp.o 
/usr/bin/c++ -DAPP_PROFILE -DDEBUG -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -I/your-path/cpp-imgu/src/core -I/your-path/cpp-imgu/build/debug/_deps/fmt-src/include -I/your-path/cpp-imgu/build/debug/_deps/spdlog-src/include -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include/SDL2 -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include-config-debug/SDL2 -I/your-path/cpp-imgu/build/debug/_deps/imgui-src -I/your-path/cpp-imgu/src/settings -g -std=gnu++20 -O0 -fsanitize=address -g -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wformat=2 -Werror -Wmisleading-indentation -MD -MT src/core/CMakeFiles/Core.dir/Core/Log.cpp.o -MF src/core/CMakeFiles/Core.dir/Core/Log.cpp.o.d -o src/core/CMakeFiles/Core.dir/Core/Log.cpp.o -c /your-path/cpp-imgu/src/core/Core/Log.cpp
In file included from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h:41,
                 from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/chrono.h:23,
                 from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/ostream.h:23,
                 from /your-path/cpp-imgu/build/debug/_deps/spdlog-src/include/spdlog/fmt/ostr.h:21,
                 from /your-path/cpp-imgu/src/core/Core/Log.hpp:3,
                 from /your-path/cpp-imgu/src/core/Core/Log.cpp:1:
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1682:21: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1682 |   type types_[max_of(1, NUM_ARGS)];
      |               ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1683:42: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1683 |   named_arg_info<Char> named_args_[max_of(1, NUM_NAMED_ARGS)];
      |                                    ~~~~~~^~~~~~~~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1687:33: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1687 |   parse_func parse_funcs_[max_of(1, NUM_ARGS)];
      |                           ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2341:35: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2341 |   arg_t<Context, NUM_ARGS> args[1 + NUM_ARGS];
      |                                 ~~^~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2342:72: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2342 |   named_arg_info<typename Context::char_type> named_args[NUM_NAMED_ARGS];
      |                                                                        ^
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2375:52: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2375 |                     arg_t<Context, NUM_ARGS>[max_of(1, NUM_ARGS)],
      |                                              ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h: In function ‘constexpr OutputIt fmt::v11::detail::write_int(OutputIt, write_int_arg<T>, const fmt::v11::format_specs&)’:
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h:2022:15: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2022 |   char buffer[buffer_size];
      |               ^~~~~~~~~~~
cc1plus: all warnings being treated as errors
[2/13] Building CXX object src/core/CMakeFiles/Core.dir/Core/Resources.cpp.o
FAILED: src/core/CMakeFiles/Core.dir/Core/Resources.cpp.o 
/usr/bin/c++ -DAPP_PROFILE -DDEBUG -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -I/your-path/cpp-imgu/src/core -I/your-path/cpp-imgu/build/debug/_deps/fmt-src/include -I/your-path/cpp-imgu/build/debug/_deps/spdlog-src/include -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include/SDL2 -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include-config-debug/SDL2 -I/your-path/cpp-imgu/build/debug/_deps/imgui-src -I/your-path/cpp-imgu/src/settings -g -std=gnu++20 -O0 -fsanitize=address -g -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wformat=2 -Werror -Wmisleading-indentation -MD -MT src/core/CMakeFiles/Core.dir/Core/Resources.cpp.o -MF src/core/CMakeFiles/Core.dir/Core/Resources.cpp.o.d -o src/core/CMakeFiles/Core.dir/Core/Resources.cpp.o -c /your-path/cpp-imgu/src/core/Core/Resources.cpp
In file included from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h:41,
                 from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/chrono.h:23,
                 from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/ostream.h:23,
                 from /your-path/cpp-imgu/build/debug/_deps/spdlog-src/include/spdlog/fmt/ostr.h:21,
                 from /your-path/cpp-imgu/src/core/Core/Log.hpp:3,
                 from /your-path/cpp-imgu/src/core/Core/Debug/Instrumentor.hpp:12,
                 from /your-path/cpp-imgu/src/core/Core/Resources.cpp:7:
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1682:21: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1682 |   type types_[max_of(1, NUM_ARGS)];
      |               ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1683:42: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1683 |   named_arg_info<Char> named_args_[max_of(1, NUM_NAMED_ARGS)];
      |                                    ~~~~~~^~~~~~~~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1687:33: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1687 |   parse_func parse_funcs_[max_of(1, NUM_ARGS)];
      |                           ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2341:35: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2341 |   arg_t<Context, NUM_ARGS> args[1 + NUM_ARGS];
      |                                 ~~^~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2342:72: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2342 |   named_arg_info<typename Context::char_type> named_args[NUM_NAMED_ARGS];
      |                                                                        ^
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2375:52: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2375 |                     arg_t<Context, NUM_ARGS>[max_of(1, NUM_ARGS)],
      |                                              ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h: In function ‘constexpr OutputIt fmt::v11::detail::write_int(OutputIt, write_int_arg<T>, const fmt::v11::format_specs&)’:
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h:2022:15: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2022 |   char buffer[buffer_size];
      |               ^~~~~~~~~~~
cc1plus: all warnings being treated as errors
[3/13] Building CXX object src/core/CMakeFiles/Core.dir/Core/Window.cpp.o
FAILED: src/core/CMakeFiles/Core.dir/Core/Window.cpp.o 
/usr/bin/c++ -DAPP_PROFILE -DDEBUG -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -I/your-path/cpp-imgu/src/core -I/your-path/cpp-imgu/build/debug/_deps/fmt-src/include -I/your-path/cpp-imgu/build/debug/_deps/spdlog-src/include -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include/SDL2 -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include-config-debug/SDL2 -I/your-path/cpp-imgu/build/debug/_deps/imgui-src -I/your-path/cpp-imgu/src/settings -g -std=gnu++20 -O0 -fsanitize=address -g -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wformat=2 -Werror -Wmisleading-indentation -MD -MT src/core/CMakeFiles/Core.dir/Core/Window.cpp.o -MF src/core/CMakeFiles/Core.dir/Core/Window.cpp.o.d -o src/core/CMakeFiles/Core.dir/Core/Window.cpp.o -c /your-path/cpp-imgu/src/core/Core/Window.cpp
In file included from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h:41,
                 from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/chrono.h:23,
                 from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/ostream.h:23,
                 from /your-path/cpp-imgu/build/debug/_deps/spdlog-src/include/spdlog/fmt/ostr.h:21,
                 from /your-path/cpp-imgu/src/core/Core/Log.hpp:3,
                 from /your-path/cpp-imgu/src/core/Core/Debug/Instrumentor.hpp:12,
                 from /your-path/cpp-imgu/src/core/Core/Window.cpp:6:
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1682:21: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1682 |   type types_[max_of(1, NUM_ARGS)];
      |               ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1683:42: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1683 |   named_arg_info<Char> named_args_[max_of(1, NUM_NAMED_ARGS)];
      |                                    ~~~~~~^~~~~~~~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1687:33: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1687 |   parse_func parse_funcs_[max_of(1, NUM_ARGS)];
      |                           ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2341:35: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2341 |   arg_t<Context, NUM_ARGS> args[1 + NUM_ARGS];
      |                                 ~~^~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2342:72: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2342 |   named_arg_info<typename Context::char_type> named_args[NUM_NAMED_ARGS];
      |                                                                        ^
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2375:52: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2375 |                     arg_t<Context, NUM_ARGS>[max_of(1, NUM_ARGS)],
      |                                              ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h: In function ‘constexpr OutputIt fmt::v11::detail::write_int(OutputIt, write_int_arg<T>, const fmt::v11::format_specs&)’:
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h:2022:15: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2022 |   char buffer[buffer_size];
      |               ^~~~~~~~~~~
cc1plus: all warnings being treated as errors
[4/13] Building CXX object src/app/CMakeFiles/App.dir/App/Main.cpp.o
FAILED: src/app/CMakeFiles/App.dir/App/Main.cpp.o 
/usr/bin/c++ -DAPP_PROFILE -DDEBUG -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -I/your-path/cpp-imgu/src/app -I/your-path/cpp-imgu/src/core -I/your-path/cpp-imgu/build/debug/_deps/fmt-src/include -I/your-path/cpp-imgu/build/debug/_deps/spdlog-src/include -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include/SDL2 -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include-config-debug/SDL2 -I/your-path/cpp-imgu/build/debug/_deps/imgui-src -I/your-path/cpp-imgu/src/settings -g -std=gnu++20 -O0 -fsanitize=address -g -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wformat=2 -Werror -Wmisleading-indentation -MD -MT src/app/CMakeFiles/App.dir/App/Main.cpp.o -MF src/app/CMakeFiles/App.dir/App/Main.cpp.o.d -o src/app/CMakeFiles/App.dir/App/Main.cpp.o -c /your-path/cpp-imgu/src/app/App/Main.cpp
In file included from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h:41,
                 from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/chrono.h:23,
                 from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/ostream.h:23,
                 from /your-path/cpp-imgu/build/debug/_deps/spdlog-src/include/spdlog/fmt/ostr.h:21,
                 from /your-path/cpp-imgu/src/core/Core/Log.hpp:3,
                 from /your-path/cpp-imgu/src/core/Core/Debug/Instrumentor.hpp:12,
                 from /your-path/cpp-imgu/src/app/App/Main.cpp:6:
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1682:21: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1682 |   type types_[max_of(1, NUM_ARGS)];
      |               ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1683:42: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1683 |   named_arg_info<Char> named_args_[max_of(1, NUM_NAMED_ARGS)];
      |                                    ~~~~~~^~~~~~~~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1687:33: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1687 |   parse_func parse_funcs_[max_of(1, NUM_ARGS)];
      |                           ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2341:35: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2341 |   arg_t<Context, NUM_ARGS> args[1 + NUM_ARGS];
      |                                 ~~^~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2342:72: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2342 |   named_arg_info<typename Context::char_type> named_args[NUM_NAMED_ARGS];
      |                                                                        ^
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2375:52: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2375 |                     arg_t<Context, NUM_ARGS>[max_of(1, NUM_ARGS)],
      |                                              ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h: In function ‘constexpr OutputIt fmt::v11::detail::write_int(OutputIt, write_int_arg<T>, const fmt::v11::format_specs&)’:
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h:2022:15: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2022 |   char buffer[buffer_size];
      |               ^~~~~~~~~~~
cc1plus: all warnings being treated as errors
[5/13] Building CXX object src/core/CMakeFiles/Core.dir/Platform/Linux/Resources.cpp.o
FAILED: src/core/CMakeFiles/Core.dir/Platform/Linux/Resources.cpp.o 
/usr/bin/c++ -DAPP_PROFILE -DDEBUG -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -I/your-path/cpp-imgu/src/core -I/your-path/cpp-imgu/build/debug/_deps/fmt-src/include -I/your-path/cpp-imgu/build/debug/_deps/spdlog-src/include -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include/SDL2 -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include-config-debug/SDL2 -I/your-path/cpp-imgu/build/debug/_deps/imgui-src -I/your-path/cpp-imgu/src/settings -g -std=gnu++20 -O0 -fsanitize=address -g -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wformat=2 -Werror -Wmisleading-indentation -MD -MT src/core/CMakeFiles/Core.dir/Platform/Linux/Resources.cpp.o -MF src/core/CMakeFiles/Core.dir/Platform/Linux/Resources.cpp.o.d -o src/core/CMakeFiles/Core.dir/Platform/Linux/Resources.cpp.o -c /your-path/cpp-imgu/src/core/Platform/Linux/Resources.cpp
In file included from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h:41,
                 from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/chrono.h:23,
                 from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/ostream.h:23,
                 from /your-path/cpp-imgu/build/debug/_deps/spdlog-src/include/spdlog/fmt/ostr.h:21,
                 from /your-path/cpp-imgu/src/core/Core/Log.hpp:3,
                 from /your-path/cpp-imgu/src/core/Core/Debug/Instrumentor.hpp:12,
                 from /your-path/cpp-imgu/src/core/Platform/Linux/Resources.cpp:9:
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1682:21: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1682 |   type types_[max_of(1, NUM_ARGS)];
      |               ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1683:42: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1683 |   named_arg_info<Char> named_args_[max_of(1, NUM_NAMED_ARGS)];
      |                                    ~~~~~~^~~~~~~~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1687:33: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1687 |   parse_func parse_funcs_[max_of(1, NUM_ARGS)];
      |                           ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2341:35: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2341 |   arg_t<Context, NUM_ARGS> args[1 + NUM_ARGS];
      |                                 ~~^~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2342:72: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2342 |   named_arg_info<typename Context::char_type> named_args[NUM_NAMED_ARGS];
      |                                                                        ^
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2375:52: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2375 |                     arg_t<Context, NUM_ARGS>[max_of(1, NUM_ARGS)],
      |                                              ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h: In function ‘constexpr OutputIt fmt::v11::detail::write_int(OutputIt, write_int_arg<T>, const fmt::v11::format_specs&)’:
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h:2022:15: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2022 |   char buffer[buffer_size];
      |               ^~~~~~~~~~~
cc1plus: all warnings being treated as errors
[6/13] Building CXX object src/core/CMakeFiles/Core.dir/Core/Application.cpp.o
FAILED: src/core/CMakeFiles/Core.dir/Core/Application.cpp.o 
/usr/bin/c++ -DAPP_PROFILE -DDEBUG -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -I/your-path/cpp-imgu/src/core -I/your-path/cpp-imgu/build/debug/_deps/fmt-src/include -I/your-path/cpp-imgu/build/debug/_deps/spdlog-src/include -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include/SDL2 -I/your-path/cpp-imgu/build/debug/_deps/sdl2-build/include-config-debug/SDL2 -I/your-path/cpp-imgu/build/debug/_deps/imgui-src -I/your-path/cpp-imgu/src/settings -g -std=gnu++20 -O0 -fsanitize=address -g -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wformat=2 -Werror -Wmisleading-indentation -MD -MT src/core/CMakeFiles/Core.dir/Core/Application.cpp.o -MF src/core/CMakeFiles/Core.dir/Core/Application.cpp.o.d -o src/core/CMakeFiles/Core.dir/Core/Application.cpp.o -c /your-path/cpp-imgu/src/core/Core/Application.cpp
In file included from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h:41,
                 from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/chrono.h:23,
                 from /your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/ostream.h:23,
                 from /your-path/cpp-imgu/build/debug/_deps/spdlog-src/include/spdlog/fmt/ostr.h:21,
                 from /your-path/cpp-imgu/src/core/Core/Log.hpp:3,
                 from /your-path/cpp-imgu/src/core/Core/Debug/Instrumentor.hpp:12,
                 from /your-path/cpp-imgu/src/core/Core/Application.cpp:12:
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1682:21: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1682 |   type types_[max_of(1, NUM_ARGS)];
      |               ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1683:42: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1683 |   named_arg_info<Char> named_args_[max_of(1, NUM_NAMED_ARGS)];
      |                                    ~~~~~~^~~~~~~~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:1687:33: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 1687 |   parse_func parse_funcs_[max_of(1, NUM_ARGS)];
      |                           ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2341:35: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2341 |   arg_t<Context, NUM_ARGS> args[1 + NUM_ARGS];
      |                                 ~~^~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2342:72: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2342 |   named_arg_info<typename Context::char_type> named_args[NUM_NAMED_ARGS];
      |                                                                        ^
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/base.h:2375:52: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2375 |                     arg_t<Context, NUM_ARGS>[max_of(1, NUM_ARGS)],
      |                                              ~~~~~~^~~~~~~~~~~~~
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h: In function ‘constexpr OutputIt fmt::v11::detail::write_int(OutputIt, write_int_arg<T>, const fmt::v11::format_specs&)’:
/your-path/cpp-imgu/build/debug/_deps/fmt-src/include/fmt/format.h:2022:15: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2022 |   char buffer[buffer_size];

This may be issue from myside. Also one more thing do this template has any compiler preference such as clang because i am currently using gcc

Even though, with release mode i am found a way, a work-around to continue development still if you have time to look into this.

Suggestion

  • Is there a way to dockerized build system so it won't be machine dependent?? just an idea Thanks

PerHac13 avatar Aug 29 '25 20:08 PerHac13

@PerHac13 I was able to make a workaround to make the build succeed. The problematic lines are in cmake/CompilerWarnings.cmake:

...
4    option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" 0)
...
60   if (WARNINGS_AS_ERRORS)
61   message(STATUS "Treat compiler warnings as errors")
62   set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
63   set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
64   endif ()
...

Just commenting out these lines makes the build succeed (because it makes the build system ignore warnings, which isn't ideal but works for our current use case).

Now, about the containerisation. I was able to build a Docker container using a simple Dockerfile, as below:

Dockerfile code (click to expand)
FROM ubuntu:24.04

RUN apt-get update && apt-get install -y \
    cmake \
    ninja-build \
    git \
    build-essential \
    xvfb x11vnc fluxbox \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY . .

RUN rm -rf build
RUN cmake -GNinja -DCMAKE_BUILD_TYPE=Release -B build/release
RUN cmake --build build/release

CMD bash -c "Xvfb :0 -screen 0 1280x800x24 & \
        fluxbox & \
        x11vnc -display :0 -nopw -listen 0.0.0.0 -xkb -forever & \
        DISPLAY=:0 ./build/release/src/app/App"

This runs the program and sets up a VNC server for us to view the GUI from outside of the container, because Docker is headless by default. But this is where the problem arises. I cannot seem to be able to see anything on the VNC connection on my end (the TigerVNC window is just blank).

I'm running a Linux machine (Fedora 42, GNOME 48, Wayland session) and I tried to add Docker as an xhost but nothing seems to work. I get this error when running the container, which I believe is the main culprit:

[14:55:10] APP(error): Error creating SDL_Renderer!

On Windows it would be even more difficult to connect an X/Wayland session from the container, so I am not even going to try to do it (and also because I don't have a dev environment setup on Windows 😛). I am also quite new to Docker so it might be that I'm missing something obvious.

As a conclusion, all of this seems a bit too complicated just to make the builds portable... And I think it's not worth all the effort, as long as regular CMake builds work fine.

Do let me know what you think about this @PerHac13

nsh07 avatar Sep 01 '25 15:09 nsh07