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

spdlog build issue #23

Open
cst-saswatm opened this issue Aug 3, 2023 · 2 comments
Open

spdlog build issue #23

cst-saswatm opened this issue Aug 3, 2023 · 2 comments

Comments

@cst-saswatm
Copy link

When I am trying to build the cloned repo. After all the compilations and exports its failing at specially building for spdlog. I am currently using an ubuntu version 16

**----->
cmake --build _builds --config Release
[ 80%] Built target spdlog
[ 90%] Building CXX object example/CMakeFiles/example.dir/example.cpp.o
/home/saswatm/RISC-V-TLM/spdlog/example/example.cpp:267:13: error: specialization of ‘template<class T, class Char, class Enable> struct fmt::v9::formatter’ in different namespace [-fpermissive]
struct fmt::formatter<my_type> : fmt::formatterstd::string
^
In file included from /home/saswatm/RISC-V-TLM/spdlog/include/spdlog/fmt/fmt.h:27:0,
from /home/saswatm/RISC-V-TLM/spdlog/include/spdlog/common.h:45,
from /home/saswatm/RISC-V-TLM/spdlog/include/spdlog/spdlog.h:12,
from /home/saswatm/RISC-V-TLM/spdlog/example/example.cpp:29:
/home/saswatm/RISC-V-TLM/spdlog/include/spdlog/fmt/bundled/core.h:791:8: error: from definition of ‘template<class T, class Char, class Enable> struct fmt::v9::formatter’ [-fpermissive]
struct formatter {
^
example/CMakeFiles/example.dir/build.make:75: recipe for target 'example/CMakeFiles/example.dir/example.cpp.o' failed
make[2]: *** [example/CMakeFiles/example.dir/example.cpp.o] Error 1
CMakeFiles/Makefile2:125: recipe for target 'example/CMakeFiles/example.dir/all' failed
make[1]: *** [example/CMakeFiles/example.dir/all] Error 2
Makefile:155: recipe for target 'all' failed
make: *** [all] Error 2

**----->

Any suggestions how to solve it.

@AmeyaVS
Copy link
Contributor

AmeyaVS commented Aug 23, 2023

I tried the build on Ubuntu 16.04 LTS, and I was able to build(after trivial source changes), and run the example.

Can you share the build environment details?

  • Compiler used and it's version.
  • SystemC Version Used and Compilation flag used to build it.

@AmeyaVS
Copy link
Contributor

AmeyaVS commented Aug 23, 2023

After looking at the file and the line number from the error message.
It seems to be a trivial fix in the following file spdlog/example/example.cpp:

diff --git a/example/example.cpp b/example/example.cpp
index ccfdcf2..03bd27d 100644
--- a/example/example.cpp
+++ b/example/example.cpp
@@ -263,15 +263,16 @@ struct my_type
 };
 
 #ifndef SPDLOG_USE_STD_FORMAT // when using fmtlib
+namespace fmt {
 template<>
-struct fmt::formatter<my_type> : fmt::formatter<std::string>
+struct formatter<my_type> : formatter<std::string>
 {
     auto format(my_type my, format_context &ctx) -> decltype(ctx.out())
     {
         return format_to(ctx.out(), "[my_type i={}]", my.i);
     }
 };
-
+}
 #else // when using std::format
 template<>
 struct std::formatter<my_type> : std::formatter<std::string>

But I would recommend moving to a little bit modern GNU Linux System, where fixing old compiler limitations would come back to hit you at various places.

Note: Also, this project requires C++17 standard at a minimum. You will need to make additional changes in the sources to build it with GCC 5.5 that is default on Ubuntu 16.04 with only support C++11 and C++14 at a minimum.

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