none
error LNK2005 RRS feed

  • Question

  • Hi!

    Can you please tell me what I am doing wrong for recieving the follwoing linikage errors? How can I fix it?

    8>FrameLoopThread.obj : error LNK2005: "bool START_IR_TRACK" (?START_IR_TRACK@@3_NA) already defined in 3DAudioDemoDlg.obj
    8>FrameLoopThread.obj : error LNK2005: "bool STOP_IR_TRACK" (?STOP_IR_TRACK@@3_NA) already defined in 3DAudioDemoDlg.obj
    8>WiiRemoteThread.obj : error LNK2005: "bool START_IR_TRACK" (?START_IR_TRACK@@3_NA) already defined in 3DAudioDemoDlg.obj
    8>WiiRemoteThread.obj : error LNK2005: "bool STOP_IR_TRACK" (?STOP_IR_TRACK@@3_NA) already defined in 3DAudioDemoDlg.obj

    In FrameLoopThread I have:

    if(...)
     bool STOP_IR_TRACK = TRUE;
    else(...)
    bool START_IR_TRACK = TRUE;

    ---------------------------------------
    And in WiiRemoteThread :

      if(STOP_IR_TRACK == TRUE)
           {
             OutputDebugString("STOP IR_TRACKING Flag Recieved.");
            }

           else if (START_IR_TRACK == TRUE)
           {
              OutputDebugString("START IR_TRACKING Flag Recieved.");
           }

    ---------------------------------------
    And in a header file defined to both threads:

    bool START_IR_TRACK;
    bool STOP_IR_TRACK;


    Thanks!







    Monday, January 19, 2009 11:43 AM

Answers

  • As the error says, you have declared the bool variables in header file and that is included in the following  files: FrameLoopThread.cpp and 3DAudioDemoDlg.cpp. This is the issue.

    If you want to use the same variables in multiples files, declare the variables in one file and make it extern in other files.
    • Marked as answer by yade Monday, January 19, 2009 12:40 PM
    Monday, January 19, 2009 12:30 PM

All replies

  • You are declaring the same bool variable twice, once in the header file and next in the following code:

    if(...)
     bool STOP_IR_TRACK = TRUE; 
    else(...)
    bool START_IR_TRACK = TRUE;

    Remove the keyword 'bool' from the above statements.
    Monday, January 19, 2009 11:50 AM
  • I recieve exactly the same error after removing the keyword 'bool' from the statements ...

    8>Linking...
    8>FrameLoopThread.obj : error LNK2005: "bool START_IR_TRACK" (?START_IR_TRACK@@3_NA) already defined in 3DAudioDemoDlg.obj
    8>FrameLoopThread.obj : error LNK2005: "bool STOP_IR_TRACK" (?STOP_IR_TRACK@@3_NA) already defined in 3DAudioDemoDlg.obj
    8>WiiRemoteThread.obj : error LNK2005: "bool START_IR_TRACK" (?START_IR_TRACK@@3_NA) already defined in 3DAudioDemoDlg.obj
    8>WiiRemoteThread.obj : error LNK2005: "bool STOP_IR_TRACK" (?STOP_IR_TRACK@@3_NA) already defined in 3DAudioDemoDlg.obj
    8>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library


    Monday, January 19, 2009 12:13 PM
  • As the error says, you have declared the bool variables in header file and that is included in the following  files: FrameLoopThread.cpp and 3DAudioDemoDlg.cpp. This is the issue.

    If you want to use the same variables in multiples files, declare the variables in one file and make it extern in other files.
    • Marked as answer by yade Monday, January 19, 2009 12:40 PM
    Monday, January 19, 2009 12:30 PM
  • Correct ! That solved the problem!

    Thanks
    Monday, January 19, 2009 12:40 PM