2016-05-08 20 views
0
1>game.obj : error LNK2001: unresolved external symbol "public: bool __cdecl GameStore::loadFromXml(void)" ([email protected]@@QEAA_NXZ) 
1>protocolgame.obj : error LNK2001: unresolved external symbol "public: struct StoreCategory * __cdecl GameStore::getStoreCategoryByName(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ([email protected]@@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z) 
1>C:\Users\Slavi Dodo\Documents\GitHub\forgottenserver\vc14\x64\Release\theforgottenserver.exe : fatal error LNK1120: 2 unresolved externals 

私はとても混乱しています!私はなぜエラーが来るのか理解していません。「未解決の外部」を解決できません

これらは宣言「gamestore.h」

#ifndef FS_GAMESTORE_H_ADCAA356C0DB44CEBA994A0D678EC92D 
#define FS_GAMESTORE_H_ADCAA356C0DB44CEBA994A0D678EC92D 
struct StoreOffer { 
    StoreOffer(uint32_t id, uint32_t thingId, uint8_t addon, uint32_t price, uint8_t type, uint8_t state, std::string name, std::string description, std::vector<std::string> icons) 
     : id(id), thingId(thingId), addon(addon), price(price), type(type), state(state), name(name), description(description), icons(icons) {} 

    uint32_t id; 
    uint32_t thingId; 
    uint32_t price; 
    uint8_t type; 
    uint8_t state; 
    uint8_t addon; 
    std::string name; 
    std::string description; 
    std::vector<std::string> icons; 
}; 

struct StoreCategory 
{ 
    StoreCategory(std::string name, std::string description, std::vector<std::string> icons, std::vector<StoreOffer> offers) 
     : name(name), description(description), icons(icons), offers(offers) {} 

    std::string name; 
    std::string description; 
    std::string parentCategory; 
    std::vector<std::string> icons; 
    std::vector<StoreOffer> offers; 
}; 

class GameStore 
{ 
    public: 
     bool reload(); 
     bool loadFromXml(); 
     StoreOffer* getStoreItemById(uint32_t id); 
     StoreCategory* getStoreCategoryByName(const std::string& name); 

     const std::vector<StoreCategory>& getStoreCategories() const { 
      return storeCategories; 
     } 

     bool enabled; 
     std::vector<StoreCategory> storeCategories; 
}; 

#endif 

であり、これは定義「gamestore.cpp」

#include "otpch.h" 

#include "gamestore.h" 

#include "pugicast.h" 
#include "tools.h" 

bool GameStore::reload() 
{ 
    storeCategories.clear(); 
    return loadFromXml(); 
} 

bool GameStore::loadFromXml() 
{ 
    return true; 
} 

StoreOffer* GameStore::getStoreItemById(uint32_t id) { 
    for (auto it : storeCategories) { 
     for (auto item : it.offers) { 
      if (item.id == id) { 
       return &item; 
      } 
     } 
    } 
    return nullptr; 
} 

StoreCategory* GameStore::getStoreCategoryByName(const std::string& name) { 
    auto it = std::find_if(storeCategories.begin(), storeCategories.end(), [name](StoreCategory& storeCategory) { 
     return storeCategory.name == name; 
    }); 
    return it != storeCategories.end() ? &*it : nullptr; 
} 

である私は、エラーの詳細読み、それでも発見していません私の状況に対する解決策。 「loadFromXml」がtrueを返すだけで、引数を受け入れずに公開されているので、問題は非常に混乱しています。

+0

私は全く助けになりません! –

+0

reopened:OPはリンクによって助けられませんでした(これは想像力の伸びによって「正確な重複」ではありません) –

+0

実際に 'gamestore.cpp'をコンパイルしているかどうかを確認します –

答えて

0

gamestore.cppがコンパイルされているかどうかを確認してください。

CLCompileリストのプロジェクト名 .vcprojに追加しない場合。

関連する問題