Linker Error (LNK2019) when Building Project

closed account (49iURXSz)
Ok, so this is related to my other question's project (Dice Game) here ( http://www.cplusplus.com/forum/beginner/117780/ ).

What I don't understand is I have:

* defined function prototypes, all in the fProtoType.hpp file

* declared functions, some distributed in iMessaging.cpp and others in iDiceFunct.cpp (diceFunct.cpp)

Yet, I run into the following output on build:

( Excrept )

1>playGame.obj : error LNK2019: unresolved external symbol "int __cdecl sumTotalDieLeft(int * const,int)" 
(?sumTotalDieLeft@@YAHQAHH@Z) referenced in function "void __cdecl playGame(void)" (?playGame@@YAXXZ)

1>playGame.obj : error LNK2019: unresolved external symbol "class Dice __cdecl drawDice(int * const,int)" 
(?drawDice@@YA?AVDice@@QAHH@Z) referenced in function "void __cdecl playGame(void)" (?playGame@@YAXXZ)

1>playGame.obj : error LNK2019: unresolved external symbol "int __cdecl rollDice(class Dice)" 
(?rollDice@@YAHVDice@@@Z) referenced in function "void __cdecl playGame(void)" (?playGame@@YAXXZ)

1>N:\cPlusPlus\submoduleDieProb\Debug\submoduleDieProb.exe : fatal error LNK1120: 3 unresolved externals


I've tried cleaning up and rebuilding, but I have the feeling I'm forgetting some sort of "best practice" coding technique in my source somewhere...

iDieFunct.cpp (dieFunct.cpp) Excrept
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "fProtoType.hpp"

[...] <- Some other code

int sumTotalDieLeft ( int totalUp[], int arraySize)
{
	int accumulator = 0;

	for ( int iElement = 0; iElement < arraySize; iElement++ )
	{
		accumulator += totalUp[iElement];
	}

	return accumulator;
}


fProtoType.hpp Excrept
 
int sumTotalDieLeft( int[], int );


playGame.cpp Excrept
1
2
3
4
5
6
7
8
9
10
#include "fProtoType.hpp"

playGame()
{

[...] <- Some other code

totalDieLeft = sumTotalDieLeft ( dieTypeIDLeft, DIE_TYPES );

}


By the way, I really appreciate the active responses from the community on the previous question. Glad you guys can take the time to show me a trick or two!
Last edited on
closed account (49iURXSz)
I don't understand why it is a problem. I've made the declaration and definition ( implementation ); I should be able to call it.

If the answer lies within templates, I'll be lost for a while. Most of what I've learned so far from C++ comes from either Starting Out With C++: Form Controls Through Objects, or StackOverflow...
closed account (49iURXSz)
I've noticed that all of the functions that get linker errors utilize other functions that are in the same translation unit. Perhaps by moving them outside to another T.U. will fix the problem.
closed account (49iURXSz)
That only gave me more garbage...


1>iProbFunct.obj : error LNK2019: unresolved external symbol "private: __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE@ABV01@@Z) referenced in function "int __cdecl zonePick(double * const,int)" (?zonePick@@YAHQANH@Z)
1>iProbFunct.obj : error LNK2001: unresolved external symbol "private: __thiscall std::basic_ios<char,struct std::char_traits<char> >::basic_ios<char,struct std::char_traits<char> >(class std::basic_ios<char,struct std::char_traits<char> > const &)" (??0?$basic_ios@DU?$char_traits@D@std@@@std@@AAE@ABV01@@Z)
1>iProbFunct.obj : error LNK2001: unresolved external symbol "private: __thiscall std::basic_ostream<char,struct std::char_traits<char> >::basic_ostream<char,struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > const &)" (??0?$basic_ostream@DU?$char_traits@D@std@@@std@@AAE@ABV01@@Z)
1>iProbFunct.obj : error LNK2001: unresolved external symbol "private: __thiscall std::ios_base::ios_base(class std::ios_base const &)" (??0ios_base@std@@AAE@ABV01@@Z)
1>playGame.obj : error LNK2019: unresolved external symbol "class Dice __cdecl drawDice(int * const,int)" (?drawDice@@YA?AVDice@@QAHH@Z) referenced in function "void __cdecl playGame(void)" (?playGame@@YAXXZ)
1>playGame.obj : error LNK2019: unresolved external symbol "int __cdecl rollDice(class Dice)" (?rollDice@@YAHVDice@@@Z) referenced in function "void __cdecl playGame(void)" (?playGame@@YAXXZ)
closed account (49iURXSz)
See last post for solution at the link below:

http://www.cplusplus.com/forum/beginner/117842/
Topic archived. No new replies allowed.