linking/compiling errors

This is a discussion on linking/compiling errors within the C++ Programming forums, part of the General Programming Boards category; No matter what I do I always ERROR LNK2005 and the best I've done is narrowed it down to just ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    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, 04:44 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 05:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21