Upon updating vcpkg (and therefore {fmt} from 7.0.3 to 7.1.0, see #14239), I can no longer build a project that uses quill.
Host Environment
cl.exe 19.27.29112)Failure logs
quill.lib(FileUtilities.cpp.obj) : error LNK2019: unresolved external symbol "struct fmt::v7::detail::dragonbox::decimal_fp<float> __cdecl fmt::v7::detail::dragonbox::to_decimal<float>(float)" (??$to_decimal@M@dragonbox@detail@v7@fmt@@YA?AU?$decimal_fp@M@0123@M@Z) referenced in function "class fmt::v7::detail::buffer_appender<wchar_t> __cdecl fmt::v7::detail::write<wchar_t,class fmt::v7::detail::buffer_appender<wchar_t>,float,0>(class fmt::v7::detail::buffer_appender<wchar_t>,float)" (??$write@_WV?$buffer_appender@_W@detail@v7@fmt@@M$0A@@detail@v7@fmt@@YA?AV?$buffer_appender@_W@012@V3012@M@Z)
quill.lib(FileUtilities.cpp.obj) : error LNK2019: unresolved external symbol "struct fmt::v7::detail::dragonbox::decimal_fp<double> __cdecl fmt::v7::detail::dragonbox::to_decimal<double>(double)" (??$to_decimal@N@dragonbox@detail@v7@fmt@@YA?AU?$decimal_fp@N@0123@N@Z) referenced in function "class fmt::v7::detail::buffer_appender<wchar_t> __cdecl fmt::v7::detail::write<wchar_t,class fmt::v7::detail::buffer_appender<wchar_t>,double,0>(class fmt::v7::detail::buffer_appender<wchar_t>,double)" (??$write@_WV?$buffer_appender@_W@detail@v7@fmt@@N$0A@@detail@v7@fmt@@YA?AV?$buffer_appender@_W@012@V3012@N@Z)
References
To Reproduce
main.cpp:main.cpp
#include <quill/Quill.h>
int main()
{
quill::enable_console_colours();
quill::start();
quill::Logger *logger = quill::get_logger();
logger->set_log_level(quill::LogLevel::TraceL3);
// enable a backtrace that will get flushed when we log CRITICAL
logger->init_backtrace(2, quill::LogLevel::Critical);
LOG_BACKTRACE(logger, "Backtrace log {}", 1);
LOG_BACKTRACE(logger, "Backtrace log {}", 2);
LOG_INFO(logger, "Welcome to Quill!");
LOG_ERROR(logger, "An error message. error code {}", 123);
LOG_WARNING(logger, "A warning message.");
LOG_CRITICAL(logger, "A critical error.");
LOG_DEBUG(logger, "Debugging foo {}", 1234);
LOG_TRACE_L1(logger, "{:>30}", "right aligned");
LOG_TRACE_L2(logger, "Positional arguments are {1} {0} ", "too", "supported");
LOG_TRACE_L3(logger, "Support for floats {:03.2f}", 1.23456);
}
CMakeLists.txt:cmake_minimum_required(VERSION 3.18)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake
CACHE STRING "Vcpkg toolchain file")
set(VCPKG_TARGET_TRIPLET "x64-windows" CACHE STRING "")
project(main VERSION 1.0.0)
add_executable(main main.cpp)
find_package(quill CONFIG REQUIRED)
target_link_libraries(main PRIVATE quill::quill)
vcpkg.json:{
"name": "main",
"version-string": "1.0.0",
"dependencies": [
"quill"
]
}
mkdir quill_build_failure
cd quill_build_failure
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
:: <create main.cpp, CMakeLists.txt, and vcpkg.json>
cd ..
mkdir build
cd build
cmake -G Ninja ..
cmake --build .
/cc @LilyWangL @BillyONeal
I was mistaken about the cause. I think the issue is caused by the recent upgrade of {fmt} to version 7.1.0 (#14239). I've opened an issue on quill (odygrd/quill#63) requesting that it upgrade to {fmt} 7.1. I've updated the description.
quill uses lib fmt directly from vcpkg and doesn't have any internal dependencies that need to be changed to support the new lib fmt version.
can you please try to rebuild quill via vcpkg after you have upgraded lib fmt
@odygrd I was successfully able to build quill itself, cloning it from GitHub, at the latest commit. However, even when I deleted, re-cloned and re-built vcpkg from the latest commit e9ff3cd5a04cd0e8122ff56e9873985ff71aa3ca, the error still occurs.
I was able to build a simple project using vcpkg and fmt 7.1, and I was even able to build spdlog with fmt v7.1, but building quill with 7.1 keeps failing, even on a fresh project.
But when I checkout vcpkg to commit 0ff75ac80b9a3770afb3d2971c572628d80a631e (the commit right before the one that update fmt to 7.1), I can build my project that uses quill successfully.
Is it possible that quill has copy/pasta'd some fmt bits inside?
I did some asking around https://twitter.com/MalwareMinigun/status/1323129471503724544
It looks that fmt switch to Dragonbox for the default floating-point formatting from https://github.com/fmtlib/fmt/releases/tag/7.1.0, fmt requires Dragonbox dependency, which doesn't support in vcpkg.
cc @cngzhnp
I tried to install quill via vcpkg and had no issues
PS C:\dev\vcpkg> .\vcpkg.exe install quill --triplet x64-windows
Computing installation plan...
The following packages will be built and installed:
* fmt[core]:x64-windows
quill[core]:x64-windows
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-windows...
Starting package 1/2: fmt:x64-windows
Could not locate cached archive: C:\Users\ody\AppData\Local\vcpkg\archives\ab\ab09657f636ef3bc7ec12311d3b63944d9ed09e6.zip
-- Using cached C:/dev/vcpkg/downloads/fmtlib-fmt-4fe0b11195b7cd71f39253c44db2c9dddf6b82d4.tar.gz
-- Extracting source C:/dev/vcpkg/downloads/fmtlib-fmt-4fe0b11195b7cd71f39253c44db2c9dddf6b82d4.tar.gz
-- Applying patch fix-warning4189.patch
-- Using source at C:/dev/vcpkg/buildtrees/fmt/src/dddf6b82d4-f2c5fef865.clean
-- Configuring x64-windows
-- Building x64-windows-dbg
-- Building x64-windows-rel
-- Installing: C:/dev/vcpkg/packages/fmt_x64-windows/share/fmt/copyright
-- Using msys root at C:/dev/vcpkg/downloads/tools/msys2/c809757c94447846
-- Fixing pkgconfig file: C:/dev/vcpkg/packages/fmt_x64-windows/lib/pkgconfig/fmt.pc
-- Fixing pkgconfig file: C:/dev/vcpkg/packages/fmt_x64-windows/debug/lib/pkgconfig/fmt.pc
-- Installing: C:/dev/vcpkg/packages/fmt_x64-windows/share/fmt/usage
-- Performing post-build validation
-- Performing post-build validation done
Stored binary cache: C:\Users\ody\AppData\Local\vcpkg\archives\ab\ab09657f636ef3bc7ec12311d3b63944d9ed09e6.zip
Building package fmt[core]:x64-windows... done
Installing package fmt[core]:x64-windows...
Installing package fmt[core]:x64-windows... done
Elapsed time for package fmt:x64-windows: 13.84 s
Starting package 2/2: quill:x64-windows
Building package quill[core]:x64-windows...
Could not locate cached archive: C:\Users\ody\AppData\Local\vcpkg\archives\fc\fcd47f59d7caddf55dcf353c604d9832b7540586.zip
-- Note: quill only supports static library linkage. Building static library.
-- Using cached C:/dev/vcpkg/downloads/odygrd-quill-94cecd870236410016db692a68114e547be6578c.tar.gz
-- Extracting source C:/dev/vcpkg/downloads/odygrd-quill-94cecd870236410016db692a68114e547be6578c.tar.gz
-- Using source at C:/dev/vcpkg/buildtrees/quill/src/547be6578c-7ff6c4afcc.clean
-- Configuring x64-windows
-- Building x64-windows-dbg
-- Building x64-windows-rel
-- Installing: C:/dev/vcpkg/packages/quill_x64-windows/share/quill/copyright
-- Performing post-build validation
-- Performing post-build validation done
Stored binary cache: C:\Users\ody\AppData\Local\vcpkg\archives\fc\fcd47f59d7caddf55dcf353c604d9832b7540586.zip
Building package quill[core]:x64-windows... done
Installing package quill[core]:x64-windows...
Installing package quill[core]:x64-windows... done
Elapsed time for package quill:x64-windows: 30.94 s
Total elapsed time: 49.77 s
The package quill:x64-windows provides CMake targets:
find_package(quill CONFIG REQUIRED)
target_link_libraries(main PRIVATE quill::quill)
PS C:\dev\vcpkg> .\vcpkg.exe list
fmt:x64-windows 7.1.0 Formatting library for C++. It can be used as a ...
gtest:x64-windows 2019-10-09-1 GoogleTest and GoogleMock testing frameworks.
gtest:x86-windows 2019-10-09-1 GoogleTest and GoogleMock testing frameworks.
quill:x64-windows 1.4.1 C++14 Asynchronous Low Latency Logging Library
Building quill is fine, however when using the port in above example project, it links failed.
@PhoebeHui @BillyONeal fmt 7.1.1 has been released. I updated my local fmt port and rebuilt but the issue still persists. If there is no more to do regarding updating fmt than I've already done, I'll be happy to open PR. https://github.com/bl-ue/vcpkg/tree/fmt-711-issue-14354
@bl-ue, please open a PR for the new revision. I also noticed that quill update the internal fmt to 7.1.0, it might need to update it togather.
@PhoebeHui @BillyONeal unfortunately, I deleted and re-cloned my local vcpkg after my PR was merged, but the issue remains.
Well, the fmt author said it has been fixed in fmt 7.1.1 from https://twitter.com/vzverovich/status/1323271537139437570. looks this still be a problem with fmt 7.1.1.
I poked them again.
Not sure if that helps, but quill always includes fmt like this:
For vckpg we always #define QUILL_FMT_EXTERNAL so it will always include and use any fmt header that is already installed in the system and the internal fmt library is ignored.
The internal fmt library is not even included in the build
I think this is a libfmt issue. @vitaut
For now quill will use the following workaround that seems to work.
https://github.com/odygrd/quill/commit/bd9815048368d221b38c2b46c1beb4ddb893b0bc
The symbols are defined here: https://github.com/fmtlib/fmt/blob/506ff320f2bf85b3d685c67358994026a2110e84/src/format.cc#L27-L30. Feel free to open an issue in {fmt} with a repro.
Not sure why it happens, but quill is trying to link against the system wide installed lib fmt when QUILL_FMT_EXTERNAL is defined but still the symbols are not found.
https://github.com/odygrd/quill/blob/master/quill/CMakeLists.txt#L150
Most helpful comment
I poked them again.