在将这个库导入到我的c++项目中时,我遇到了这个问题。当我生成dll解决方案时,Visual Studio抛出错误"Unresolved Symbol“,并在我删除类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);
}
}我已经读了一个关于这个问题的问题,但老实说,我不明白解决方案,这是在下一段代码:链接到答案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%$");
}
}答案是将这些声明为Log的一部分!但我不知道这是什么意思,我是C++的新手。
发布于 2020-05-22 09:17:54
除了Log.h之外,所有东西都在Thigre名称空间下,由于某种原因,Log.h在Hazel名称空间下。也许能解决你的问题。在复制和粘贴代码时,请确保更改了所有内容。
https://stackoverflow.com/questions/61945749
复制相似问题