mariusmm / RISC-V-TLM

RISC-V SystemC-TLM simulator
GNU General Public License v3.0
278 stars 72 forks source link

spdlog build issue #23

Open cst-saswatm opened 1 year ago

cst-saswatm commented 1 year ago

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 : fmt::formatter ^ 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 commented 1 year ago

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?

AmeyaVS commented 1 year ago

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.