0

Update: I finally could solve this problem on my own after (see below [#Solution]) this post getting automaticaly flagged as CLOSED & some further hours of digging the web & some helpful comments - Huge thanks! This post solved the issue.

I'm getting a bunch of undefined reference to fmt::v9::vformat[abi:cxx11](fmt::v9::basic_string_view<char> with my current cmake project while trying to include the shared system spdlog libara, which bundels the fmt libaray (als dynamicly compiled in) which seem to cause the issues. All my libraries are placed in the /usr/include/ directory of my Linux distro (regular pacman, Arch Linux).

The errors seem to be specific to the fmt library...

The one & only CMakeList.txt:

cmake_minimum_required(VERSION 3.24) # cmake v3.24 used too
project(snake)

set(CMAKE_CXX_STANDARD 20)

add_library(spdlog SHARED IMPORTED)
add_library(fmt SHARED IMPORTED)
target_link_libraries(spdlog)
target_link_libraries(fmt)
#[[
add_library(fmt SHARED IMPORTED)# Tried this, result's the same
add_compile_definitions(SPDLOG_FMT_EXTERNAL_HO)  # "
]]
add_library(boost SHARED IMPORTED)

find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
qt_standard_project_setup()

add_executable(snake src/main.cpp src/SnakeGameFrame.cpp src/Snake.cpp)

target_link_libraries(snake PRIVATE Qt6::Widgets)

Includes in Snake.hpp:

#include <QPoint>
#include <spdlog/sinks/stdout_color_sinks.h>
/*
#define FMT_HEADER_ONLY Things I played around with...
#include <fmt/core.h>
#include <fmt/format.h>
#include <fmt/format-inl.h>
#include <fmt/ranges.h>
*/

#include <deque>

//...
class Snake
{
 private:
    static const std::shared_ptr<spdlog::logger> console_logger;

    std::deque<QPoint> m_body;
    QPoint m_head;
    std::int32_t m_length;
    Direction m_view_direction;
    /// Stored as ms for updating the QFrame, less -> faster
    std::int32_t m_movement_speed;

 public:
    explicit Snake(const QPoint& start = { 42, 42 }, const Direction direction = Direction::WEST)
        : m_head(start), m_length(2), m_view_direction(direction), m_movement_speed(80)
    {
        assert(m_head.x() >= 0 && m_head.y() >= 0);

        // Setup of body & head
        m_body = {m_head};

        QPoint bodyPoint{m_head};
        for (int i = 1; i < m_length; ++i)
        {
            bodyPoint += getDirectionsRelativeCoords(m_view_direction);
            m_body.push_back(bodyPoint);
        }

        // Logging
        console_logger->info("Created from {:d},{:d} to {:d},{:d}:\n",
            m_body.front().x(), m_body.front().y(), m_body.back().x(), m_body.back().y());
    }

    auto move();
    auto turn(const Direction direction) -> void;
    auto grow();
    auto isEatingItself() -> bool;
    auto getHead() -> QPoint&;
    auto getBody() -> std::pair<QPoint, QPoint>;
    auto getLegth() -> std::int32_t;

 private:
    /**
     * Return the relative position point to a given direction.
     * E.g. if NORTH is the argument, the return value is (-1,0) which should be equals
     * the northern direction in QT applications
     * @param direction
     * @return
     */
    auto getDirectionsRelativeCoords(Direction direction) -> QPoint;
};

Built command from CLion (trimmed, error persists on experimantal GCC 13 and stable Clang 15):

CLion-cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -G Ninja -S ~/code/CLionProjects/snake -B ~/code/CLionProjects/snake/build-debug

The linker log:

[6/6] Linking CXX executable snake
FAILED: snake
: && /usr/bin/clang++ -g  CMakeFiles/snake.dir/snake_autogen/mocs_compilation.cpp.o CMakeFiles/snake.dir/src/main.cpp.o CMakeFiles/snake.dir/src/SnakeGameFrame.cpp.o CMakeFiles/snake.dir/src/Snake.cpp.o -o snake  /usr/lib/libQt6Widgets.so.6.4.2  /usr/lib/libQt6Gui.so.6.4.2  /usr/lib/libQt6Core.so.6.4.2  /usr/lib/libGLX.so  /usr/lib/libOpenGL.so && :
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > fmt::v9::format<char const*, char const* const&, int const&>(fmt::v9::basic_format_string<char, fmt::v9::type_identity<char const*>::type, fmt::v9::type_identity<char const* const&>::type, fmt::v9::type_identity<int const&>::type>, char const*&&, char const* const&, int const&)':
/usr/include/fmt/core.h:3206: undefined reference to `fmt::v9::vformat[abi:cxx11](fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender, char> >)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `std::make_unsigned<long>::type fmt::v9::detail::to_unsigned<long>(long)':
/usr/include/fmt/core.h:409: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::format_decimal_result<char*> fmt::v9::detail::format_decimal<char, unsigned int>(char*, unsigned int, int)':
/usr/include/fmt/format.h:1216: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::error_handler::on_error(char const*)':
/usr/include/fmt/core.h:638: undefined reference to `fmt::v9::detail::throw_format_error(char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::format_decimal_result<char*> fmt::v9::detail::format_decimal<char, unsigned long>(char*, unsigned long, int)':
/usr/include/fmt/format.h:1216: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::format_decimal_result<char*> fmt::v9::detail::format_decimal<char, unsigned __int128>(char*, unsigned __int128, int)':
/usr/include/fmt/format.h:1216: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::appender fmt::v9::detail::write_int<char, fmt::v9::appender, unsigned int>(fmt::v9::appender, fmt::v9::detail::write_int_arg<unsigned int>, fmt::v9::basic_format_specs<char> const&, fmt::v9::detail::locale_ref)':
/usr/include/fmt/format.h:2107: undefined reference to `fmt::v9::detail::throw_format_error(char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::thousands_sep_result<char> fmt::v9::detail::thousands_sep<char>(fmt::v9::detail::locale_ref)':
/usr/include/fmt/format.h:1169: undefined reference to `fmt::v9::detail::thousands_sep_result<char> fmt::v9::detail::thousands_sep_impl<char>(fmt::v9::detail::locale_ref)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `std::make_unsigned<int>::type fmt::v9::detail::to_unsigned<int>(int)':
/usr/include/fmt/core.h:409: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::needs_escape(unsigned int)':
/usr/include/fmt/format.h:1709: undefined reference to `fmt::v9::detail::is_printable(unsigned int)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::appender fmt::v9::detail::write<char, fmt::v9::appender, float, 0>(fmt::v9::appender, float)':
/usr/include/fmt/format.h:3258: undefined reference to `fmt::v9::detail::dragonbox::decimal_fp<float> fmt::v9::detail::dragonbox::to_decimal<float>(float)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `char fmt::v9::detail::decimal_point<char>(fmt::v9::detail::locale_ref)':
/usr/include/fmt/format.h:1180: undefined reference to `char fmt::v9::detail::decimal_point_impl<char>(fmt::v9::detail::locale_ref)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::appender fmt::v9::detail::write_exponent<char, fmt::v9::appender>(int, fmt::v9::appender)':
/usr/include/fmt/format.h:1370: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::appender fmt::v9::detail::write<char, fmt::v9::appender, double, 0>(fmt::v9::appender, double)':
/usr/include/fmt/format.h:3258: undefined reference to `fmt::v9::detail::dragonbox::decimal_fp<double> fmt::v9::detail::dragonbox::to_decimal<double>(double)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::appender fmt::v9::detail::write<char, fmt::v9::appender, long double, 0>(fmt::v9::appender, long double, fmt::v9::basic_format_specs<char>, fmt::v9::detail::locale_ref)':
/usr/include/fmt/format.h:3225: undefined reference to `fmt::v9::detail::throw_format_error(char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `int fmt::v9::detail::snprintf_float<long double>(long double, int, fmt::v9::detail::float_specs, fmt::v9::detail::buffer<char>&)':
/usr/include/fmt/format.h:1582: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: /usr/include/fmt/format.h:1583: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `int fmt::v9::detail::format_float<long double>(long double, int, fmt::v9::detail::float_specs, fmt::v9::detail::buffer<char>&)':
/usr/include/fmt/format.h:3104: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `void fmt::v9::detail::bigint::operator=<unsigned __int128>(unsigned __int128)':
/usr/include/fmt/format.h:2814: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::bigint::operator<<=(int)':
/usr/include/fmt/format.h:2823: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o:/usr/include/fmt/format.h:2814: more undefined references to `fmt::v9::detail::assert_fail(char const*, int, char const*)' follow
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::adjust_precision(int&, int)':
/usr/include/fmt/format.h:2610: undefined reference to `typeinfo for fmt::v9::format_error'
/usr/bin/ld: /usr/include/fmt/format.h:2610: undefined reference to `fmt::v9::format_error::~format_error()'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::bigint::divmod_assign(fmt::v9::detail::bigint const&)':
/usr/include/fmt/format.h:2949: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: /usr/include/fmt/format.h:2951: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::format_error::format_error(char const*)':
/usr/include/fmt/format.h:951: undefined reference to `vtable for fmt::v9::format_error'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::bigint::subtract_aligned(fmt::v9::detail::bigint const&)':
/usr/include/fmt/format.h:2744: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: /usr/include/fmt/format.h:2745: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::appender fmt::v9::detail::write<char, fmt::v9::appender>(fmt::v9::appender, char const*)':
/usr/include/fmt/format.h:3324: undefined reference to `fmt::v9::detail::throw_format_error(char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::appender fmt::v9::detail::write<char, fmt::v9::appender>(fmt::v9::appender, fmt::v9::monostate, fmt::v9::basic_format_specs<char>, fmt::v9::detail::locale_ref)':
/usr/include/fmt/format.h:3272: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `char const* fmt::v9::detail::do_parse_arg_id<char, fmt::v9::detail::parse_replacement_field<char, fmt::v9::detail::vformat_to<char>(fmt::v9::detail::buffer<char>&, fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<std::conditional<std::is_same<fmt::v9::type_identity<char>::type, char>::value, fmt::v9::appender, std::back_insert_iterator<fmt::v9::detail::buffer<fmt::v9::type_identity<char>::type> > >::type, fmt::v9::type_identity<char>::type> >, fmt::v9::detail::locale_ref)::format_handler&>(char const*, char const*, fmt::v9::detail::vformat_to<char>(fmt::v9::detail::buffer<char>&, fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<std::conditional<std::is_same<fmt::v9::type_identity<char>::type, char>::value, fmt::v9::appender, std::back_insert_iterator<fmt::v9::detail::buffer<fmt::v9::type_identity<char>::type> > >::type, fmt::v9::type_identity<char>::type> >, fmt::v9::detail::locale_ref)::format_handler&)::id_adapter&>(char const*, char const*, fmt::v9::detail::vformat_to<char>(fmt::v9::detail::buffer<char>&, fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<std::conditional<std::is_same<fmt::v9::type_identity<char>::type, char>::value, fmt::v9::appender, std::back_insert_iterator<fmt::v9::detail::buffer<fmt::v9::type_identity<char>::type> > >::type, fmt::v9::type_identity<char>::type> >, fmt::v9::detail::locale_ref)::format_handler&)':
/usr/include/fmt/core.h:2406: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `int fmt::v9::detail::parse_nonnegative_int<char>(char const*&, char const*, int)':
/usr/include/fmt/core.h:2338: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `char const* fmt::v9::detail::parse_align<char, fmt::v9::detail::specs_checker<fmt::v9::detail::specs_handler<char> >&>(char const*, char const*, fmt::v9::detail::specs_checker<fmt::v9::detail::specs_handler<char> >&)':
/usr/include/fmt/core.h:2362: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `char const* fmt::v9::detail::parse_width<char, fmt::v9::detail::specs_checker<fmt::v9::detail::specs_handler<char> >&>(char const*, char const*, fmt::v9::detail::specs_checker<fmt::v9::detail::specs_handler<char> >&)':
/usr/include/fmt/core.h:2459: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::fill_t<char>::operator=(fmt::v9::basic_string_view<char>)':
/usr/include/fmt/core.h:2095: undefined reference to `fmt::v9::detail::throw_format_error(char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `char const* fmt::v9::detail::do_parse_arg_id<char, fmt::v9::detail::parse_width<char, fmt::v9::detail::specs_checker<fmt::v9::detail::specs_handler<char> >&>(char const*, char const*, fmt::v9::detail::specs_checker<fmt::v9::detail::specs_handler<char> >&)::width_adapter&>(char const*, char const*, fmt::v9::detail::specs_checker<fmt::v9::detail::specs_handler<char> >&)':
/usr/include/fmt/core.h:2406: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `char const* fmt::v9::detail::do_parse_arg_id<char, fmt::v9::detail::parse_precision<char, fmt::v9::detail::specs_checker<fmt::v9::detail::specs_handler<char> >&>(char const*, char const*, fmt::v9::detail::specs_checker<fmt::v9::detail::specs_handler<char> >&)::precision_adapter&>(char const*, char const*, fmt::v9::detail::specs_checker<fmt::v9::detail::specs_handler<char> >&)':
/usr/include/fmt/core.h:2406: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::appender fmt::v9::detail::write_int<char, fmt::v9::appender, unsigned long>(fmt::v9::appender, fmt::v9::detail::write_int_arg<unsigned long>, fmt::v9::basic_format_specs<char> const&, fmt::v9::detail::locale_ref)':
/usr/include/fmt/format.h:2107: undefined reference to `fmt::v9::detail::throw_format_error(char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::appender fmt::v9::detail::write_int<char, fmt::v9::appender, unsigned __int128>(fmt::v9::appender, fmt::v9::detail::write_int_arg<unsigned __int128>, fmt::v9::basic_format_specs<char> const&, fmt::v9::detail::locale_ref)':
/usr/include/fmt/format.h:2107: undefined reference to `fmt::v9::detail::throw_format_error(char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::appender fmt::v9::detail::write<char, fmt::v9::appender, float, 0>(fmt::v9::appender, float, fmt::v9::basic_format_specs<char>, fmt::v9::detail::locale_ref)':
/usr/include/fmt/format.h:3225: undefined reference to `fmt::v9::detail::throw_format_error(char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `int fmt::v9::detail::snprintf_float<double>(double, int, fmt::v9::detail::float_specs, fmt::v9::detail::buffer<char>&)':
/usr/include/fmt/format.h:1582: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: /usr/include/fmt/format.h:1583: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `int fmt::v9::detail::format_float<double>(double, int, fmt::v9::detail::float_specs, fmt::v9::detail::buffer<char>&)':
/usr/include/fmt/format.h:3104: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: /usr/include/fmt/format.h:3135: undefined reference to `fmt::v9::detail::dragonbox::decimal_fp<float> fmt::v9::detail::dragonbox::to_decimal<float>(float)'
/usr/bin/ld: /usr/include/fmt/format.h:3139: undefined reference to `fmt::v9::detail::dragonbox::decimal_fp<double> fmt::v9::detail::dragonbox::to_decimal<double>(double)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::grisu_gen_digits(fmt::v9::detail::basic_fp<unsigned long long>, unsigned long, int&, fmt::v9::detail::gen_digits_handler&)':
/usr/include/fmt/format.h:2626: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: /usr/include/fmt/format.h:2627: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: /usr/include/fmt/format.h:2688: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::detail::get_round_direction(unsigned long, unsigned long, unsigned long)':
/usr/include/fmt/format.h:2543: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: /usr/include/fmt/format.h:2544: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o:/usr/include/fmt/format.h:2545: more undefined references to `fmt::v9::detail::assert_fail(char const*, int, char const*)' follow
/usr/bin/ld: CMakeFiles/snake.dir/src/main.cpp.o: in function `fmt::v9::appender fmt::v9::detail::write<char, fmt::v9::appender, double, 0>(fmt::v9::appender, double, fmt::v9::basic_format_specs<char>, fmt::v9::detail::locale_ref)':
/usr/include/fmt/format.h:3225: undefined reference to `fmt::v9::detail::throw_format_error(char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/SnakeGameFrame.cpp.o: in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > fmt::v9::format<std::deque<QPoint, std::allocator<QPoint> >&>(fmt::v9::basic_format_string<char, fmt::v9::type_identity<std::deque<QPoint, std::allocator<QPoint> >&>::type>, std::deque<QPoint, std::allocator<QPoint> >&)':
/usr/include/fmt/core.h:3206: undefined reference to `fmt::v9::vformat[abi:cxx11](fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender, char> >)'
/usr/bin/ld: CMakeFiles/snake.dir/src/SnakeGameFrame.cpp.o: in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > fmt::v9::format<char const*, char const*&, int&>(fmt::v9::basic_format_string<char, fmt::v9::type_identity<char const*>::type, fmt::v9::type_identity<char const*&>::type, fmt::v9::type_identity<int&>::type>, char const*&&, char const*&, int&)':
/usr/include/fmt/core.h:3206: undefined reference to `fmt::v9::vformat[abi:cxx11](fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender, char> >)'
/usr/bin/ld: CMakeFiles/snake.dir/src/SnakeGameFrame.cpp.o: in function `fmt::v9::basic_memory_buffer<char, 250ul, std::allocator<char> >::operator=(fmt::v9::basic_memory_buffer<char, 250ul, std::allocator<char> >&&)':
/usr/include/fmt/format.h:884: undefined reference to `fmt::v9::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/snake.dir/src/SnakeGameFrame.cpp.o: in function `decltype (({parm#1}.begin)()) fmt::v9::range_formatter<QPoint, char, void>::parse<fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler> >(fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler>&)':
/usr/include/fmt/ranges.h:492: undefined reference to `typeinfo for fmt::v9::format_error'
/usr/bin/ld: /usr/include/fmt/ranges.h:492: undefined reference to `fmt::v9::format_error::~format_error()'
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

I've seen the official fmt usage doc, but I think it should generally not be necessary to build or download something into my project root or build fmt from scratch, when it's already installed on my system...

I've read some related articles like this post yet but somehow can't figure out wahts wrong. I'd be REALLY glad for some advices/ requests for more infos to provide.

Solution:

It seems like the linker could not properly figure out the definitions of the fmt library:

add_library(spdlog SHARED IMPORTED)
add_library(fmt SHARED IMPORTED)
set_target_properties(fmt PROPERTIES IMPORTED_LOCATION /lib/libfmt.so) # <- THIS!
#add_compile_definitions(SPDLOG_FMT_EXTERNAL_HO) # Seems to be enabled by default

# ...

target_link_libraries(snake PRIVATE Qt6::Widgets fmt)
[6/6] Linking CXX executable snake

Build finished

If you might have any idea why I had to do this for fmt, but spdfmt being recognized without any problems, I'd be really glad for a comment :)

jnnk
  • 1
  • 1

0 Answers0