Thread: linking/compiling errors

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    48

    linking/compiling errors

    No matter what I do I always ERROR LNK2005 and the best I've done is narrowed it down to just one "TicTacToe.obj : error LNK2005: "struct tictactoe tic" (?tic@@3Utictactoe@@A) already defined in Test.obj". What are some common mistakes made with this error and what can I do to fix it?

    My files in the project are

    Test.cpp (The main file)
    Include files:
    #include <windows.h>
    #include <iostream>
    #include "TicTacToe.h"
    using namespace std;

    TicTacToe.h (The file with the class definition)

    TicTacToe.cpp (The file with all of the constructors)
    #include <iostream.h>
    #include <windows.h>
    #include "TicTacToe.h"

    So what's wrong with my linking? Any help would be greatly appreciated. Um... thx
    Hey, you gotta start somewhere

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    In your .h file, you should have

    extern struct tictactoe tic;

    In ONE .cpp file, you should have
    struct tictactoe tic;

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    48
    thx, that worked. Lol, that was the quickest response i ever got.
    Hey, you gotta start somewhere

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  3. Winsock compilation errors
    By jmd15 in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-03-2005, 08:00 AM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 06:51 PM