Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > LNK2005 error

Reply
Thread Tools

LNK2005 error

 
 
Taran
Guest
Posts: n/a
 
      06-15-2006
Hi all,

I have this config.h file which has all the declarations for the vars
being used in the application. There are no compilation errors but link
errors for all the vars declared in this "iof_config.h" file.

//************************************************** **
//FILE : iof_library.h
//************************************************** **

#ifndef IOF_CONFIG_H
#define IOF_CONFIG_H 1

#include "iof_library.h"
// my own library for open, read and write to the queue,
// write to producer queue and read to consumer queue
#include "C_Q_Iterator_FIFO.h" // Q Iterators
#include "C_Q_Iterator_LastProduce.h"
#include "GeneralUtilities.h"


//************************************************** *************/
// This data comes from the XML file
//Array of all the producers
// Where:
// Producer 0 = Altitude
// Producer 1 = Airspeed
// Producer 2 = Pressure
// Producer 3 = Temperature
//************************************************** *************/
const int Produced_Items =4;


//************************************************** *************/
// Array of all the consumers
// Where:
// Consumer 0 = Knots, FIFO read
// Consumer 1 = Degree Celcius, Last Produced read //Always reads the
last value i.e.from the tail
// Consumer 2 = Feet, FIFO read
// Consumer 3 = psi, LastProduced read
//************************************************** *************/
const int Consumed_Items =4;

///************************************************** ******
// C_Queue instantions for the Producers
//************************************************** ******

//For Produced Item 1
C_Queue<Queue_Element> altitude(9, "Altitude");

//For Produced Item 2
C_Queue<Queue_Element> airspeed(5, "Airspeed");

//For Produced Item 3
C_Queue<Queue_Element> pressure(12, "Pressure");

//For Produced Item 4
C_Queue<Queue_Element> temperature(3, "Temperature");

//************************************************** ******
// C_Q_Iterator instantions for the Consumers
//************************************************** ******

//Consumed Item 1
C_Q_Iterator_FIFO<Queue_Element> altitude_iterator(&altitude, "Feet");

//Consumed Item 2
C_Q_Iterator_FIFO<Queue_Element> airspeed_iterator(&airspeed,"Knots");

//Consumed Item 3
C_Q_Iterator_LastProduce<Queue_Element>
pressure_iterator(&pressure,"PSI");

//Consumed Item 4
C_Q_Iterator_LastProduce<Queue_Element>
temperature_iterator(&temperature,"Degrees");


//************************************************** *************/
//Producer and Consumer Arrays
//************************************************** *************/
C_Queue<Queue_Element>* Producer[Produced_Items];
C_Q_Iterator<Queue_Element>* Consumer[Consumed_Items];

//************************************************** *************/
// Arrays for holding the unused indices in Producer and Consumer
arrays
// There can be max Produced(Consumed)_Items number of unused indices.
//************************************************** *************/
int empty_producer_indices[Produced_Items];
int empty_consumer_indices[Consumed_Items];

#endif

I am unable to understand that even though the file is inclusion
protected and there are only declarations why is this error.

Error message:

iof_library.obj : error LNK2005: "void __cdecl populate(void)"
(?populate@@YAXXZ) already defined in AppFile.obj
iof_library.obj : error LNK2005: "class C_Queue<struct Queue_Element> *
* Producer" (?Producer@@3PAPAV?$C_Queue@UQueue_Element@@@@A) already
defined in AppFile.obj
iof_library.obj : error LNK2005: "class C_Queue<struct Queue_Element>
pressure" (?pressure@@3V?$C_Queue@UQueue_Element@@@@A) already defined
in AppFile.obj
iof_library.obj : error LNK2005: "class C_Queue<struct Queue_Element>
temperature" (?temperature@@3V?$C_Queue@UQueue_Element@@@@A) already
defined in AppFile.obj
iof_library.obj : error LNK2005: "class C_Q_Iterator<struct
Queue_Element> * * Consumer"
(?Consumer@@3PAPAV?$C_Q_Iterator@UQueue_Element@@@ @A) already defined
in AppFile.obj
iof_library.obj : error LNK2005: "int * empty_producer_indices"
(?empty_producer_indices@@3PAHA) already defined in AppFile.obj
iof_library.obj : error LNK2005: "class C_Q_Iterator_FIFO<struct
Queue_Element> altitude_iterator"
(?altitude_iterator@@3V?$C_Q_Iterator_FIFO@UQueue_ Element@@@@A) already
defined in AppFile.obj
iof_library.obj : error LNK2005: "class C_Q_Iterator_LastProduce<struct
Queue_Element> temperature_iterator"
(?temperature_iterator@@3V?$C_Q_Iterator_LastProdu ce@UQueue_Element@@@@A)
already defined in AppFile.obj
iof_library.obj : error LNK2005: "int * empty_consumer_indices"
(?empty_consumer_indices@@3PAHA) already defined in AppFile.obj
iof_library.obj : error LNK2005: "class C_Queue<struct Queue_Element>
altitude" (?altitude@@3V?$C_Queue@UQueue_Element@@@@A) already defined
in AppFile.obj
iof_library.obj : error LNK2005: "class C_Queue<struct Queue_Element>
airspeed" (?airspeed@@3V?$C_Queue@UQueue_Element@@@@A) already defined
in AppFile.obj
iof_library.obj : error LNK2005: "class C_Q_Iterator_FIFO<struct
Queue_Element> airspeed_iterator"
(?airspeed_iterator@@3V?$C_Q_Iterator_FIFO@UQueue_ Element@@@@A) already
defined in AppFile.obj
iof_library.obj : error LNK2005: "class C_Q_Iterator_LastProduce<struct
Queue_Element> pressure_iterator"
(?pressure_iterator@@3V?$C_Q_Iterator_LastProduce@ UQueue_Element@@@@A)
already defined in AppFile.obj


The file App.obj just incudes iof_library.h. The vars declared in this
iof_library.h are not declared anywhere else. And only the vars in this
file are causing this link error.

Am I missing something here?

I am using MVisual Studio 6.

Thanks in Advance.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
msvcprt.lib (msvcp60.dll) LNK2005 error Angus C++ 2 12-28-2006 02:32 AM
Visual Studio 2003 linker error LNK2005 ivan C++ 2 08-04-2006 03:33 PM
LNK2005 error Taran C++ 3 06-22-2006 05:20 PM
How to resolve error LNK2005 - function already defined Angus Comber C Programming 1 01-08-2005 03:30 PM
LNK2005-error in Visual C++ v. 6.0 Jon C++ 3 08-25-2004 09:41 PM



Advertisments