Help figuring out the unresolved externals errors?
Write your question here.
I keep getting these errors. But i cant figure out what library i didnt call
1 2 3 4
|
Error 4 error LNK1120: 2 unresolved externals
Error 1 error LNK2001: unresolved external symbol "private: virtual void __thiscall SceneNode::drawCurrent(class sf::RenderTarget &,class sf::RenderStates)const " (?drawCurrent@SceneNode@@EBEXAAVRenderTarget@sf@@VRenderStates@3@@Z)
Error 2 error LNK2001: unresolved external symbol "private: virtual void __thiscall SceneNode::drawCurrent(class sf::RenderTarget &,class sf::RenderStates)const " (?drawCurrent@SceneNode@@EBEXAAVRenderTarget@sf@@VRenderStates@3@@Z)
Error 3 error LNK2019: unresolved external symbol "public: class sf::Texture const & __thiscall ResourceHolder<class sf::Texture,enum Textures::ID>::get(enum Textures::ID)const " (?get@?$ResourceHolder@VTexture@sf@@W4ID@Textures@@@@QBEABVTexture@sf@@W4ID@Textures@@@Z) referenced in function "public: __thiscall Aircraft::Aircraft(enum Aircraft::Type,class ResourceHolder<class sf::Texture,enum Textures::ID> const &)" (??0Aircraft@@QAE@W4Type@0@ABV?$ResourceHolder@VTexture@sf@@W4ID@Textures@@@@@Z)
|
Here are all the header files
SceneNode.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#pragma once
#ifdef SFML_STATIC
#pragma comment(lib, "glew.lib")
#pragma comment(lib, "freetype.lib")
#pragma comment(lib, "jpeg.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "gdi32.lib")
#endif // SFML_STATIC
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include<assert.h>
#include<map>
#include <iostream>
#include <vector>
#include <memory>
class SceneNode : public sf::Transformable, public sf::Drawable,private sf::NonCopyable
{
public:
typedef std::unique_ptr<SceneNode> Ptr;
SceneNode();
void attachChild(Ptr child);
Ptr detachChild(const SceneNode& node);
void update(sf::Time dt);
sf::Transform getWorldTransform() const;
sf::Vector2f getWorldPosition() const;
private:
std::vector<Ptr> mChildren;
SceneNode* mParent;
void updateChldrean(sf::Time dt); // update for the child nodes
virtual void draw(sf::RenderTarget &target, sf::RenderStates states) const final;
virtual void drawCurrent(sf::RenderTarget &target, sf::RenderStates states) const;
virtual void updateCurrent(sf::Time dt); // update for the current nodes
};
|
ResourceHolder.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#pragma once
#ifdef SFML_STATIC
#pragma comment(lib, "glew.lib")
#pragma comment(lib, "freetype.lib")
#pragma comment(lib, "jpeg.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "gdi32.lib")
#endif // SFML_STATIC
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include<assert.h>
#include<map>
#include <iostream>
#include <memory>
#include <string>
using namespace std;
template<typename Resource, typename Identifier>
class ResourceHolder{
public:
void load(Identifier id, const std::string &filename);
template<typename Parameter>
void load(Identifier id, const std::string &filename, const Parameter &secondParam);
Resource &get(Identifier id);
const Resource &get(Identifier id) const;
private:
void insertResource(Identifier id, std::unique_ptr<Resource> resource);
private:
std::map<Identifier, std::unique_ptr<Resource>> mResourceMap;
};
|
Aircraft.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#pragma once
#ifdef SFML_STATIC
#pragma comment(lib, "glew.lib")
#pragma comment(lib, "freetype.lib")
#pragma comment(lib, "jpeg.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "gdi32.lib")
#endif // SFML_STATIC
#include "Entity.h"
#include "ResourceIdentifiers.h"
#include "ResourceHolder.h"
class Aircraft : public Entity
{
public:
enum Type{
Eagle,
Raptor
};
Aircraft(Type type, const TextureHolder& textures);
private:
virtual void drawCurrent(sf::RenderTarget &target, sf::RenderStates states) const;
private:
Type mType;
sf::Sprite mSprite;
};
|
There is something missing in SceneNode class and Aircraft class.
Error is all about the virtual function of SceneNode and Aircraft. and get() of ResourceHolder.
I search on this error and some said that I access an object but the linker cant find the definition?
Everything is defined on header. and header is included on every cpp class.. How can i have this error?
Topic archived. No new replies allowed.