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++.