T
Taran
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_LastProduce@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.
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_LastProduce@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.