错误:
2\>main.obj : error LNK2019: unresolved external symbol "public: void \__cdecl Engine::Components::Model_Component::manolo(void)" (?manolo@Model_Component@Components@Engine@@QEAAXXZ) referenced in function "void \__cdecl configure2(class Engine::Scene &)" (?configure2@@YAXAEAVScene@Engine@@@Z)
2\>C:\\Users\\Vicen\\Desktop\\Animacion3D\\Desarollo\\Game\\projects\\visual-studio-2022\\x64\\Debug\\Game.exe : fatal error LNK1120: 1 unresolved externals
所有引擎代码都是静态库
标题:
#pragma once
#include <string>
#include "maths.hpp"
#include "Component.hpp"
// Forward Declaration
namespace glt
{
class Model;
}
namespace Engine::Components
{
struct Model_Component : public Component
{
std::string path;
std::shared_ptr< glt::Model > model;
Model_Component(std::string given_path) : path(given_path), model(nullptr) {}
~Model_Component() = default;
void manolo();
};
}
来源:
#include <Node.hpp>
#include <Model.hpp>
#include <Model_Obj.hpp>
#include <Render_Node.hpp>
// Custom
#include "../headers/Entity.hpp"
#include "../headers/Model_Component.hpp"
namespace Engine::Components
{
void Model_Component::manolo()
{
}
}
我不明白为什么它不起作用,我需要一点帮助。
要解决 suce 错误,您必须将所有 .cpp 文件添加到您的项目中。
一旦添加包含
void Model_Component::manolo() {}
(即您问题中的文件)的 .cpp 文件,链接器错误就会消失。
如何将 .cpp 文件添加到您的项目中:
如果您使用的是 Makefile,请将其添加到 Makefile(与已添加的其他 .cpp 文件类似)。
如果您使用的是 IDE,请将其添加到您的项目设置中。如果您还没有项目,请先创建一个。