C++ compile error

Joined
Apr 26, 2008
Messages
4
Reaction score
0
Points
1
Hi,

I'm having trouble with an example from a C++ book.

Using eclipse 3.32 on OS X 10.4.11, gcc version 4.0.1, I get this error message:

Code:
**** Build of configuration Debug for project ticTacToe ****

make all 
Building file: ../src/ticTacToe.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ticTacToe.d" -MT"src/ticTacToe.d" -o"src/ticTacToe.o" "../src/ticTacToe.cpp"
Finished building: ../src/ticTacToe.cpp
 
Building target: ticTacToe
Invoking: MacOS X C++ Linker
g++  -o "ticTacToe"  ./src/ticTacToe.o   
/usr/bin/ld: Undefined symbols:
displayBoard(std::vector<char, std::allocator<char> > const&)
collect2: ld returned 1 exit status
make: *** [ticTacToe] Error 1

I then tried to compile it in Xcode 2.2.1, and it compiles but then crashes soon after running with this error message:

Code:
ZeroLink: unknown symbol '__Z12displayBoardRKSt6vectorIcSaIcEE'

tictactoe has exited due to signal 6 (SIGABRT).

If I comment out this function and all calls to the function, I don't get any errors and it compiles and runs.

Code:
void dipslayBoard(const vector<char>& board)
{
	cout << "\n\t" << board[0] << " | " << board[1] << " | " << board[2];
	cout << "\n\t" << "--------";
	cout << "\n\t" << board[3] << " | " << board[4] << " | " << board[5];
	cout << "\n\t" << "--------";
	cout << "\n\t" << board[6] << " | " << board[7] << " | " << board[8];
	cout << "\n\n";
}

Any ideas?

Thanks,

Jim.
 
Joined
May 2, 2008
Messages
3
Reaction score
0
Points
1
your linker is not linking properly. tell your linker where to look, -L/WHERETOLOOK, then tell which lib it need, -l/LIBINEED
 
Joined
Mar 15, 2007
Messages
161
Reaction score
4
Points
18
Your Mac's Specs
17" MacBook Pro, 2.33GHz C2D, 2GB RAM
If you copied the code into your message above verbatim from your source file, note that the function name is dipslayBoard() (including the typo of the reversed 'p' and 's'). If your calls to the function are expecting the name to be displayBoard(), as the linker error suggests, that would explain why the function appears to be missing at link time, and correcting the function's name should resolve the issue.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top