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

Compile error on VS2019 x86 #1596

Closed
caa-energid opened this issue Jun 18, 2020 · 4 comments
Closed

Compile error on VS2019 x86 #1596

caa-energid opened this issue Jun 18, 2020 · 4 comments

Comments

@caa-energid
Copy link

caa-energid commented Jun 18, 2020

We have a customer that is using VS 2019 32-bit / the x64 version builds just fine.
Here is the output from compiling file_sinks.cpp

Building CXX object CMakeFiles\spdlog.dir\src\file_sinks.cpp.obj
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/fmt/bundled/core.h(1354):
  error C2672: 'fmt::v6::internal::make_arg': no matching overloaded function
  found
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/fmt/bundled/core.h(1349):
  note: while compiling class template member function
  'fmt::v6::format_arg_store<fmt::v6::basic_format_context<std::back_insert_iterator<fmt::v6::internal::buffer<char>>,char>,std::basic_string<char,std::char_traits<char>,std::allocator<char>>,unsigned
  int,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>::format_arg_store(const
  std::basic_string<char,std::char_traits<char>,std::allocator<char>> &,const
  unsigned int &,const
  std::basic_string<char,std::char_traits<char>,std::allocator<char>> &)'
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/fmt/bundled/core.h(1656):
  note: see reference to function template instantiation
  'fmt::v6::format_arg_store<fmt::v6::basic_format_context<std::back_insert_iterator<fmt::v6::internal::buffer<char>>,char>,std::basic_string<char,std::char_traits<char>,std::allocator<char>>,unsigned
  int,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>::format_arg_store(const
  std::basic_string<char,std::char_traits<char>,std::allocator<char>> &,const
  unsigned int &,const
  std::basic_string<char,std::char_traits<char>,std::allocator<char>> &)'
  being compiled
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/fmt/bundled/core.h(1747):
  note: see reference to class template instantiation
  'fmt::v6::format_arg_store<fmt::v6::basic_format_context<std::back_insert_iterator<fmt::v6::internal::buffer<char>>,char>,std::basic_string<char,std::char_traits<char>,std::allocator<char>>,unsigned
  int,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>'
  being compiled
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/sinks/rotating_file_sink-inl.h(53):
  note: see reference to function template instantiation
  'std::basic_string<char,std::char_traits<char>,std::allocator<char>>
  fmt::v6::format<char[8],spdlog::filename_t&,size_t&,spdlog::filename_t&,char>(const
  S (&),spdlog::filename_t &,size_t &,spdlog::filename_t &)' being compiled
          with
          [
              S=char [8]
          ]
 
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/sinks/rotating_file_sink-inl.h(45):
  note: while compiling class template member function 'spdlog::filename_t
  spdlog::sinks::rotating_file_sink<std::mutex>::calc_filename(const
  spdlog::filename_t &,size_t)'
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/sinks/rotating_file_sink-inl.h(33):
  note: see reference to function template instantiation 'spdlog::filename_t
  spdlog::sinks::rotating_file_sink<std::mutex>::calc_filename(const
  spdlog::filename_t &,size_t)' being compiled
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\src\file_sinks.cpp(19):
  note: see reference to class template instantiation
  'spdlog::sinks::rotating_file_sink<std::mutex>' being compiled
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/fmt/bundled/core.h(1356):
  error C2783: 'fmt::v6::internal::value<Context>
  fmt::v6::internal::make_arg(const T &)': could not deduce template argument
  for 'Context'
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/fmt/bundled/core.h(1216):
  note: see declaration of 'fmt::v6::internal::make_arg'
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/fmt/bundled/core.h(1356):
  error C2783: 'fmt::v6::internal::value<Context>
  fmt::v6::internal::make_arg(const T &)': could not deduce template argument
  for '__formal'
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/fmt/bundled/core.h(1216):
  note: see declaration of 'fmt::v6::internal::make_arg'
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/fmt/bundled/core.h(1356):
  error C2974: 'fmt::v6::internal::make_arg': invalid template argument for
  'Context', type expected
  
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog\include\spdlog/fmt/bundled/core.h(904):
  note: see declaration of 'fmt::v6::internal::make_arg'

I did see a bugs posted against fmtlib here and here.
But since we are using the latest version of fmtlib, both bug-fixes have been incorporated into our code base.

Please advise
Thanks in advance

@tt4g
Copy link
Contributor

tt4g commented Jun 19, 2020

I can build the following code with spdlog v1.6.1 on Visual Studio 2019 16.6.2 (14.26.28801).

#include <spdlog/spdlog.h>
#include <spdlog/sinks/basic_file_sink.h>

#include <memory>

int main(int, char**)
{
    auto logger = spdlog::basic_logger_mt("foo", "foo.txt");

    logger->info("Hello, World!");

    return 0;
}
Build log
$ mkdir build
$ cd build
$ cmake .. -G "Visual Studio 16 2019" -A Win32
-- The C compiler identification is MSVC 19.26.28806.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x86/cl.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is MSVC 19.26.28806.0
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x86/cl.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build spdlog: 1.6.1
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Build type: Release
-- Generating example(s)
-- Generating install
-- Configuring done
-- Generating done
-- Build files have been written to: (omit)/spdlog/build
$ cmake --build . --target
(omit)
$ Debug\foo
$ type foo.txt
[2020-06-19 10:24:47.849] [foo] [info] Hello, World!

<\details>

Could you provide snippet to reproduce?
and It is recommended to open the issue fmt repository.

@caa-energid
Copy link
Author

In your example above, it appears that you are using the spdlog lib to link to the HelloWorld example.
In my case, I am unable to build file_sinks.cpp from the cloned github repo.

Performing configure step for 'spdlog'
  -- The C compiler identification is MSVC 19.21.27702.2
  -- Check for working C compiler: C:/clcache/clcache.exe
  -- Check for working C compiler: C:/clcache/clcache.exe - works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- The CXX compiler identification is MSVC 19.21.27702.2
  -- Check for working CXX compiler: C:/clcache/clcache.exe
  -- Check for working CXX compiler: C:/clcache/clcache.exe - works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Build spdlog: 1.6.1
  -- Looking for pthread.h
  -- Looking for pthread.h - not found
  -- Found Threads: TRUE
  -- Build type: Release
  -- Generating install
  -- Configuring done
  -- Generating done
  -- Build files have been written to:
  C:/j/workspace/acmasterall19/591af00f/build/ExternalProjects/spdlog/spdlog-prefix/src/spdlog-build
Performing build step for 'spdlog'
  FAILED: spdlog-prefix/src/spdlog-stamp/spdlog-build

  cmd.exe /C "cd /D
  C:\j\workspace\acmasterall19\591af00f\build\ExternalProjects\spdlog\spdlog-prefix\src\spdlog-build
  && C:\cmake\bin\cmake.exe --build .  && C:\cmake\bin\cmake.exe -E touch
  C:/j/workspace/acmasterall19/591af00f/build/ExternalProjects/spdlog/spdlog-prefix/src/spdlog-stamp/spdlog-build"
  [1/9] Building CXX object CMakeFiles\spdlog.dir\src\cfg.cpp.obj
  [2/9] Building CXX object CMakeFiles\spdlog.dir\src\async.cpp.obj
  [3/9] Building CXX object CMakeFiles\spdlog.dir\src\color_sinks.cpp.obj
  [4/9] Building CXX object CMakeFiles\spdlog.dir\src\stdout_sinks.cpp.obj
  [5/9] Building RC object CMakeFiles\spdlog.dir\version.rc.res
  Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
  Copyright (C) Microsoft Corporation.  All rights reserved.

  [6/9] Building CXX object CMakeFiles\spdlog.dir\src\file_sinks.cpp.obj

Then it fails as noted above

@tt4g
Copy link
Contributor

tt4g commented Jun 19, 2020

MSVC 19.21.27702.2 has template problem: https://developercommunityapi.westus.cloudapp.azure.com/content/problem/535251/msvc-1920275081-does-not-accept-a-simple-tempate-t.html
Try update current version 19.26.28806.0.

@caa-energid
Copy link
Author

Confirmed that it DOES indeed build with version 19.26.28806.0
Thanks much

bachittle pushed a commit to bachittle/spdlog that referenced this issue Dec 22, 2022
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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

2 participants