0
votes

First a little code:

class CDb
{
public:
    void CreateLeague(const League &data);
protected:
    int InsertOwners(const std::vector<std::string> &owners, int leagueId);
};

void CDb::CreateLeague(const League &data)
{
    // some code 
    if( InsertOwners( data.GetOwners(), leagueId ) != SQLITE_OK )
    {
      // ROLLBACK transaction
    }
}

int CDb::InsertOwners(const std::vector<std::string> &owners, int leagueId)
{
}

Function GetOwners() is declared as:

std::vector<std::string> &GetOwners() const;

During linking I'm getting following:

unresolved external symbol "protected: int __thiscall CDb::InsertOwners(class std::vector,class std::allocator >,class std::allocator,class std::allocator > > > const &,int)" (?InsertOwners@CDb@@IAEHABV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@H@Z) referenced in function "public: void __thiscall CDb::CreateLeague(class CLeagueSettings const &)" (?CreateLeague@CDb@@QAEXABVCLeagueSettings@@@Z) 1>vc_mswud\baseballdraft.exe : fatal error LNK1120: 1 unresolved externals

Using MSVC 2010 on Windows 7.

Please help.

2
Are you sure the file that contains the implementation of CDb::InsertOwners() is part of the project and actually getting compiled?Frédéric Hamidi

2 Answers

0
votes

Ensure that following code gets compiled:

int CDb::InsertOwners(const std::vector<std::string> &owners, int leagueId) 
{ 
} 

Check if this is into another source file (.CPP), and that particular file is included in project. If this is actual code, it would give error, since it is missing return statement.

0
votes

It is hard to give you a definite solution looking at your code snippet.

What is "data" type?

I suspect is that you are using some kind of library that you implicit link with your app. You have all declarations of the types and functions for data but you do not link with the .lib module, hence GetOwners implementation is not visible and this causes linker to scream.

Another possibility is that you have data type (class?) declared but an implementation file (cpp) is not included in your project therefore data.GetOwners() causes linker error by the same reason as above: no implementation visible..