Thread: Variables already defined while linking.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User xconspirisist's Avatar
    Join Date
    Nov 2003
    Posts
    44

    Variables already defined while linking.

    I've not written C in quite a while, sorry if I'm looking over something obvious.

    Here is camera.h

    Code:
    float angle=0.0, deltaAngle = 0.0, ratio;
    float x=0.0f, y=1.75f, z=5.0f;
    float lx=0.0f, ly=0.0f, lz=-1.0f;
    
    int deltaMove = 0;
    Then I'm just using

    Code:
    #include "camera.h"
    in each file where I need those variables. However, during link, I get these errors:

    keys.obj : error LNK2005: "int deltaMove" (?deltaMove@@3HA) already defined in camera.obj
    keys.obj : error LNK2005: "float lz" (?lz@@3MA) already defined in camera.obj
    keys.obj : error LNK2005: "float ly" (?ly@@3MA) already defined in camera.obj
    keys.obj : error LNK2005: "float lx" (?lx@@3MA) already defined in camera.obj
    keys.obj : error LNK2005: "float z" (?z@@3MA) already defined in camera.obj
    keys.obj : error LNK2005: "float y" (?y@@3MA) already defined in camera.obj
    keys.obj : error LNK2005: "float x" (?x@@3MA) already defined in camera.obj
    keys.obj : error LNK2005: "float deltaAngle" (?deltaAngle@@3MA) already defined in camera.obj
    keys.obj : error LNK2005: "float angle" (?angle@@3MA) already defined in camera.obj
    keys.obj : error LNK2005: "float ratio" (?ratio@@3MA) already defined in camera.obj
    render.obj : error LNK2005: "int deltaMove" (?deltaMove@@3HA) already defined in camera.obj
    render.obj : error LNK2005: "float lz" (?lz@@3MA) already defined in camera.obj
    render.obj : error LNK2005: "float ly" (?ly@@3MA) already defined in camera.obj
    render.obj : error LNK2005: "float lx" (?lx@@3MA) already defined in camera.obj
    render.obj : error LNK2005: "float z" (?z@@3MA) already defined in camera.obj
    render.obj : error LNK2005: "float y" (?y@@3MA) already defined in camera.obj
    render.obj : error LNK2005: "float x" (?x@@3MA) already defined in camera.obj
    render.obj : error LNK2005: "float deltaAngle" (?deltaAngle@@3MA) already defined in camera.obj
    render.obj : error LNK2005: "float angle" (?angle@@3MA) already defined in camera.obj
    render.obj : error LNK2005: "float ratio" (?ratio@@3MA) already defined in camera.obj
    To surpress any confusion, camera.h is included in camera.cpp, keys.cpp and render.cpp

    Please help, I'm quite clueless to the issue. :/
    Last edited by xconspirisist; 06-10-2005 at 03:15 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Best way to avoid using global variables
    By Canadian0469 in forum C++ Programming
    Replies: 7
    Last Post: 12-18-2008, 12:02 PM
  2. Replies: 15
    Last Post: 09-30-2008, 02:12 AM
  3. esbo's data sharing example
    By esbo in forum C Programming
    Replies: 49
    Last Post: 01-08-2008, 11:07 PM
  4. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  5. Linking images to variables
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 10-12-2001, 12:07 PM