Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actuallride

Posted 08 November 2012 - 10:52 PM

I fixed the error and now must define a constructor

ResourceManager.h
[source lang="cpp"]#pragma once#include <unordered_map>#include <utility> //for std::pair#include <SFML/Audio.hpp>#include <string>template<class T> class Resource;template<class T> class ResourceManager{friend class Resource<T>;};template<>class ResourceManager<sf::Music>{private: std::unordered_map<std::string, std::pair<int, sf::Music>> resourceMap;public: ResourceManager();}; ResourceManager<sf::Music>::ResourceManager(){}[/source]

Resource.h
[source lang="cpp"]#pragma once#include <SFML\Audio.hpp>#include "ResourceManager.h"template<> class Resource<sf::Music>{private: static ResourceManager<sf::Music> manager;};[/source]

When I compile this, I get linker error
1>HomeMenuScene.obj : error LNK2005: "public: __thiscall ResourceManager<class sf::Music>::ResourceManager<class sf::Music>(void)" (??0?$ResourceManager@VMusic@sf@@@@QAE@XZ) already defined in LogicManager.obj
1>main.obj : error LNK2005: "public: __thiscall ResourceManager<class sf::Music>::ResourceManager<class sf::Music>(void)" (??0?$ResourceManager@VMusic@sf@@@@QAE@XZ) already defined in LogicManager.obj
1>PlayingScene.obj : error LNK2005: "public: __thiscall ResourceManager<class sf::Music>::ResourceManager<class sf::Music>(void)" (??0?$ResourceManager@VMusic@sf@@@@QAE@XZ) already defined in LogicManager.obj
1>SettingMenuScene.obj : error LNK2005: "public: __thiscall ResourceManager<class sf::Music>::ResourceManager<class sf::Music>(void)" (??0?$ResourceManager@VMusic@sf@@@@QAE@XZ) already defined in LogicManager.obj
1>C:\Users\Park\Documents\Visual Studio 2012\Projects\Game3\Debug\Game3.exe : fatal error LNK1169: one or more multiply defined symbols found

#4lride

Posted 08 November 2012 - 10:27 PM

I think the error is due to circular referencing in header files.
But I'm confused about how to correct this.

#3lride

Posted 08 November 2012 - 10:27 PM

I think the error is due to circular referencing in header files.
But I'm confused about how to correct this.

#2lride

Posted 08 November 2012 - 10:27 PM

I think the error is due to circular referencing in header files.
But I'm confused about how to correct this.

#1lride

Posted 08 November 2012 - 10:27 PM

I think the error is due to circular referencing in header files.
But I'm confused how to correct this.

PARTNERS