Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build project failed #2713

Closed
L-Super opened this issue Apr 21, 2023 · 3 comments
Closed

build project failed #2713

L-Super opened this issue Apr 21, 2023 · 3 comments

Comments

@L-Super
Copy link

L-Super commented Apr 21, 2023

env:

  • Windows11
  • Qt 5.15.2
  • VS 2022
  • CLion 2023.1.1
  • spdlog v1.11.0 or 1.10.0
include(FetchContent)
FetchContent_Declare(spdlog
        URL https://github.com/gabime/spdlog/archive/refs/tags/v1.10.0.tar.gz
        SOURCE_DIR ${CMAKE_SOURCE_DIR}/third_party/spdlog
        DOWNLOAD_EXTRACT_TIMESTAMP true
)
FetchContent_MakeAvailable(spdlog)
...
target_link_libraries(${PROJECT_TARGET}
        Qt5::Core
        Qt5::Gui
        Qt5::Widgets
        Qt5::Svg
        libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS}
        spdlog::spdlog_header_only)

code:

MainWindow::MainWindow(QWidget *parent)
    : QWidget(parent), ui(new Ui::MainWindow), isMoving(false), browserTabWidget(new BrowserTabWidget(this))
{
    ui->setupUi(this);
    setWindowFlags(Qt::CustomizeWindowHint);
    ui->verticalLayout->addWidget(browserTabWidget);
    ui->verticalLayout->setContentsMargins(QMargins(0, 0, 0, 0));
    spdlog::info("start{}", __func__ );

When I use Clion and MSVC complier build Qt application , it build failed.Error information:

C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog\fmt\bundled\format.h(2042): error C2220: 以下警告被视为错误
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog\fmt\bundled\format.h(2042): warning C4459: “uint”的声明隐藏了全局声明
D:\Qt\5.15.2\msvc2019_64\include\QtCore/qglobal.h(275): note: 参见“uint”的声明
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog\fmt\bundled\format.h(2197): note: 查看对正在编译的函数 模板 实例化“OutputIt fmt::v8::detail::write<Char,fmt::v8::appender,T,0>(OutputIt,T)”的引用
        with
        [
            OutputIt=fmt::v8::appender,
            Char=char,
            T=double
        ]
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog\fmt\bundled\core.h(1611): note: 查看对正在编译的函数 模板 实例化“fmt::v8::appender fmt::v8::detail::default_arg_formatter<Char>::operator ()<double>(T)”的引用
        with
        [
            Char=char,
            T=double
        ]
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog\fmt\bundled\core.h(1611): note: 查看对正在编译的函数 模板 实例化“fmt::v8::appender fmt::v8::detail::default_arg_formatter<Char>::operator ()<double>(T)”的引用
        with
        [
            Char=char,
            T=double
        ]
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog\fmt\bundled\format.h(2931): note: 查看对正在编译的函数 模板 实例化“fmt::v8::appender fmt::v8::visit_format_arg<fmt::v8::detail::default_arg_formatter<Char>,Context>(Visitor &&,const fmt::v8::basic_format_arg<Context> &)”的引用
        with
        [
            Char=char,
            Context=fmt::v8::format_context,
            Visitor=fmt::v8::detail::default_arg_formatter<char>
        ]
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog\fmt\bundled\format-inl.h(2588): note: 查看对正在编译的函数 模板 实例化“void fmt::v8::detail::vformat_to<char>(fmt::v8::detail::buffer<char> &,fmt::v8::basic_string_view<char>,fmt::v8::basic_format_args<fmt::v8::format_context>,fmt::v8::detail::locale_ref)”的引用
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog\fmt\bundled\format.h(1270): warning C4459: “uint”的声明隐藏了全局声明
D:\Qt\5.15.2\msvc2019_64\include\QtCore/qglobal.h(275): note: 参见“uint”的声明
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog\fmt\bundled\format.h(2052): note: 查看对正在编译的函数 模板 实例化“fmt::v8::detail::dragonbox::float_info<double>::carrier_uint fmt::v8::detail::exponent_mask<floaty>(void)”的引用
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog\fmt\bundled\format.h(2197): note: 查看对正在编译的函数 模板 实例化“OutputIt fmt::v8::detail::write<Char,fmt::v8::appender,T,0>(OutputIt,T)”的引用
        with
        [
            OutputIt=fmt::v8::appender,
            Char=char,
            T=double
        ]
ninja: build stopped: subcommand failed.

When I changed CMakeLists.txt:

    target_link_libraries(${PROJECT_TARGET}
            Qt5::Core
            Qt5::Gui
            Qt5::Widgets
            Qt5::Svg
            libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS}
            spdlog)

The error info:

[1/21] Automatic MOC and UIC for target spdlog
[2/21] Building CXX object _deps\spdlog-build\CMakeFiles\spdlog.dir\spdlog_autogen\mocs_compilation.cpp.obj
[3/21] Building CXX object _deps\spdlog-build\CMakeFiles\spdlog.dir\src\file_sinks.cpp.obj
[4/21] Building CXX object _deps\spdlog-build\CMakeFiles\spdlog.dir\src\async.cpp.obj
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog/async_logger-inl.h(62): warning C4530: 使用了 C++ 异常处理程序,但未启用展开语义。请指定 /EHsc
[5/21] Building CXX object _deps\spdlog-build\CMakeFiles\spdlog.dir\src\cfg.cpp.obj
D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\string(36): warning C4530: 使用了 C++ 异常处理程序,但未启用展开语义。请指定 /EHsc
D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\string(79): note: 查看对正在编译的函数 模板 实例化“std::basic_istream<char,std::char_traits<char>> &std::getline<char,std::char_traits<char>,std::allocator<char>>(std::basic_istream<char,std::char_traits<char>> &&,std::basic_string<char,std::char_traits<char>,std::allocator<char>> &,const _Elem)”的引用
        with
        [
            _Elem=char
        ]
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog/cfg/helpers-inl.h(70): note: 查看对正在编译的函数 模板 实例化“std::basic_istream<char,std::char_traits<char>> &std::getline<char,std::char_traits<char>,std::allocator<char>>(std::basic_istream<char,std::char_traits<char>> &,std::basic_string<char,std::char_traits<char>,std::allocator<char>> &,const _Elem)”的引用
        with
        [
            _Elem=char
        ]
[6/21] Building CXX object _deps\spdlog-build\CMakeFiles\spdlog.dir\src\color_sinks.cpp.obj
[7/21] Building CXX object _deps\spdlog-build\CMakeFiles\spdlog.dir\src\stdout_sinks.cpp.obj
[8/21] Building CXX object _deps\spdlog-build\CMakeFiles\spdlog.dir\src\fmt.cpp.obj
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog/fmt/bundled/format-inl.h(2564): warning C4530: 使用了 C++ 异常处理程序,但未启用展开语义。请指定 /EHsc
[9/21] Building CXX object _deps\spdlog-build\CMakeFiles\spdlog.dir\src\spdlog.cpp.obj
C:\Users\Listening\Documents\Workplace\cxClient\third_party\spdlog\include\spdlog/logger-inl.h(185): warning C4530: 使用了 C++ 异常处理程序,但未启用展开语义。请指定 /EHsc
[10/21] Linking CXX static library _deps\spdlog-build\spdlogd.lib

I tried two versions (V1.11.0 and V1.10.0), but both had the same results. I don't know the reason

@L-Super
Copy link
Author

L-Super commented Apr 21, 2023

I tried to change uint to uint_, it build successfully

template <typename Float>
constexpr auto exponent_mask() ->
    typename dragonbox::float_info<Float>::carrier_uint {
  using uint_ = typename dragonbox::float_info<Float>::carrier_uint;
  return ((uint_(1) << dragonbox::float_info<Float>::exponent_bits) - 1)
         << num_significand_bits<Float>();
}

image

@tt4g
Copy link
Contributor

tt4g commented Apr 21, 2023

As far as the first error message is concerned, this is a problem that has already been resolved in the fmt library (not released).
See: fmtlib/fmt#2809

However, the compiler reports warning C4459.

This is not a bug because you are handling compiler warnings as errors by the compile option /WX (C2220).

Remove the /WX option or add the /wd4459 option and ignore the warning.
See: https://learn.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170

Or use pragma to suppress warning C4459.

#pragma warning(push)
#pragma warning(disable: 4459)
#include <spdlog/spdlog.h>
#pragma warning(pop)

@L-Super
Copy link
Author

L-Super commented Apr 21, 2023

Thank you very much! I just found the answer too fmtlib/fmt#3137

@gabime gabime closed this as completed Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants