链接器无法解析外部符号
Linker can't resolve external symbols
一切都正确指示,但我仍然收到此错误:
LNK2001 未解析的外部符号“public: static bool __cdecl Logger::Logging::Init(void)” (?Init@Logging@Logger@@SA_NXZ)
Logger.h
#include <Windows.h>
#include <stdio.h>
#include <filesystem>
#include <iostream>
class Logger
{
private:
class Logging
{
public:
static inline bool Init();
}
public:
static bool Init(HINSTANCE _hinstDLL);
}
Main.cpp“我要使用功能的地方”
#pragma once
#include "Logger.h"
bool Logger::Init(HINSTANCE _hinstDLL)
{
FILE* Console;
AllocConsole();
freopen_s(&Console, "CONOUT$", "w", stdout);
if (!Logging::Init())
{
Logger::Log("Can't start the initialization!\n");
return false;
};
return true;
}
Logger.cpp“声明函数的地方”
#pragma once
#include "Cheat.h"
namespace fs = std::filesystem;
inline bool Logger::Logging::Init()
{
fs::create_directories("C:\Somewhere");
fs::path log = "C:\Somewhere\log.txt";
file = CreateFileW(log.wstring().c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
return file != INVALID_HANDLE_VALUE;
}
从 Logging::Init() 的声明和定义中删除内联解决了这个问题。
问题由@KermittheFrog 解决。
谢谢!
一切都正确指示,但我仍然收到此错误:
LNK2001 未解析的外部符号“public: static bool __cdecl Logger::Logging::Init(void)” (?Init@Logging@Logger@@SA_NXZ)
Logger.h
#include <Windows.h>
#include <stdio.h>
#include <filesystem>
#include <iostream>
class Logger
{
private:
class Logging
{
public:
static inline bool Init();
}
public:
static bool Init(HINSTANCE _hinstDLL);
}
Main.cpp“我要使用功能的地方”
#pragma once
#include "Logger.h"
bool Logger::Init(HINSTANCE _hinstDLL)
{
FILE* Console;
AllocConsole();
freopen_s(&Console, "CONOUT$", "w", stdout);
if (!Logging::Init())
{
Logger::Log("Can't start the initialization!\n");
return false;
};
return true;
}
Logger.cpp“声明函数的地方”
#pragma once
#include "Cheat.h"
namespace fs = std::filesystem;
inline bool Logger::Logging::Init()
{
fs::create_directories("C:\Somewhere");
fs::path log = "C:\Somewhere\log.txt";
file = CreateFileW(log.wstring().c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
return file != INVALID_HANDLE_VALUE;
}
从 Logging::Init() 的声明和定义中删除内联解决了这个问题。
问题由@KermittheFrog 解决。
谢谢!