0

I have this problem when importing this library into my c++ project. When I build the dll solution Visual Studio throws the error "Unresolved External Symbol" and disappears when I remove the class Log.

Log.h:

#pragma once
#include "Core.h"
#include "spdlog/spdlog.h"
#include "spdlog/sinks/stdout_color_sinks.h"

namespace Thigre {
    class THIGRE_API Log
    {
    public:
        static void Init();

        inline static std::shared_ptr<spdlog::logger>& GetCoreLogger() { return s_CoreLogger; }
        inline static std::shared_ptr<spdlog::logger>& GetClientLogger() { return s_ClientLogger; }
    private:
        static std::shared_ptr<spdlog::logger> s_CoreLogger;
        static std::shared_ptr<spdlog::logger> s_ClientLogger;
    };
}

Log.cpp:

#include "Log.h"
#include "spdlog/spdlog.h"
#include "spdlog/sinks/stdout_color_sinks.h"
namespace Thigre {
    std::shared_ptr<spdlog::logger> Log::s_CoreLogger;
    std::shared_ptr<spdlog::logger> Log::s_ClientLogger;
    void Log::Init() {
        spdlog::set_pattern("%^[%T] %n: %v%$");
        s_CoreLogger = spdlog::stdout_color_mt("THIGRE");
        s_CoreLogger->set_level(spdlog::level::trace);

        s_ClientLogger = spdlog::stdout_color_mt("MOTOR");
        s_ClientLogger->set_level(spdlog::level::trace);
    }
}

I already read a question about this same problem but honestly I didn't understand the solution, which is in the next block of code: link to the answer Here.

#include "Log.h"

namespace Hazel {

    // declare these as part of Log!
    std::shared_ptr<spdlog::logger> Log::s_CoreLogger;
    std::shared_ptr<spdlog::logger> Log::s_ClientLogger;

    void Log::Init()
    {
        spdlog::set_pattern("%^[%T] %n: %v%$");
    }

}

The answer said to declare these as part of Log! but I don't know what it means, I am new to C++.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
José Luna
  • 69
  • 1
  • 6

1 Answers1

0

Everything is under the Thigre namespace, except for Log.h, which is for some reason under the Hazel namespace. Might fix your problem. Make sure you change everything when you're copy and pasting code.

veridis_quo_t
  • 342
  • 3
  • 14
  • Sorry but the files with Thigre Namespace are mine, and the one fith Hazel namespace is one answer i found online which has the same exact problem and the solution for that in the answers was that third file: [Here](https://stackoverflow.com/questions/58479659/strange-unresolved-external-symbol-error-with-spdlog-logging-for-my-game-engin) – José Luna May 22 '20 at 05:59