Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Development and Darwin (http://www.mac-forums.com/forums/os-x-development-darwin/)
-   -   C++ compile error (http://www.mac-forums.com/forums/os-x-development-darwin/106229-c-compile-error.html)

jimz 04-26-2008 08:48 PM

C++ compile error
 
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.

KingMike 05-02-2008 12:00 PM

your linker is not linking properly. tell your linker where to look, -L/WHERETOLOOK, then tell which lib it need, -l/LIBINEED

mystic_fm 05-16-2008 04:08 AM

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.


All times are GMT -4. The time now is 06:36 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.