473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

LNK2005 error

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.

Jun 15 '06 #1
3 3119
In article <11*********************@u72g2000cwu.googlegroups. com>,
"Taran" <ta************@gmail.com> wrote:
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
You aren't showing all the code. "populate()" isn't even *in* the header
you posted.

The simple answer is, contrary to your assertion, there are not "only
declarations" in one or more of your header files.

The header you posted has several definitions in it for example.
C_Queue<Queue_Element>* Producer[Produced_Items];
C_Q_Iterator<Queue_Element>* Consumer[Consumed_Items];

int empty_producer_indices[Produced_Items];
int empty_consumer_indices[Consumed_Items];


All of the above are definitions and should not be in a header file that
is included in more than one source file.
Jun 15 '06 #2
Just before, the error lnk2005 like
" EdgeH3.obj : error LNK2005: "public: virtual void __thiscall
EdgeH3::set_order(unsigned int,enum IAGEnums::Order,bool)"
(?set_order@EdgeH3@@UAEXIW4Order@IAGEnums@@_N@Z) has defined in
BoundaryInfo.obj
Element.obj : error LNK2005: "public: virtual void __thiscall
EdgeH3::set_order(unsigned int,enum IAGEnums::Order,bool)"
(?set_order@EdgeH3@@UAEXIW4Order@IAGEnums@@_N@Z) has defined in
BoundaryInfo.obj ."
has encountered to me,, goole the webside, some useful suggestiones
have not break in my mide. So, we search codes, and then, we find that
the "inline" has been lost before defing the inline member functions(
EdgeH3::set_order(unsigned int,enum IAGEnums::Order,bool) ). at last,
my project can linked successfully after the lost " inline" words has
been added.
So, i think that maybe is the "inline" words lost before the inline
function in the header files.
Daniel T. wrote:
In article <11*********************@u72g2000cwu.googlegroups. com>,
"Taran" <ta************@gmail.com> wrote:
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


You aren't showing all the code. "populate()" isn't even *in* the header
you posted.

The simple answer is, contrary to your assertion, there are not "only
declarations" in one or more of your header files.

The header you posted has several definitions in it for example.
C_Queue<Queue_Element>* Producer[Produced_Items];
C_Q_Iterator<Queue_Element>* Consumer[Consumed_Items];

int empty_producer_indices[Produced_Items];
int empty_consumer_indices[Consumed_Items];


All of the above are definitions and should not be in a header file that
is included in more than one source file.


Jun 22 '06 #3
Renzr wrote:
Just before, the error lnk2005 like

Please don't top-post. See item 4 of the FAQ entry below:

<http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.4>

Brian
Jun 22 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Florian Liefers | last post by:
"Hello World\n", i have the following problem: One of my headerfiles for a lib is including <vector>. When i compile the lib, everything is done well. In my application another file is...
1
by: arkam | last post by:
Hi, Here are my link errors : atlsd.lib(ATLComTime.obj) : error LNK2005: "public: __thiscall ATL::COleDateTime::COleDateTime(struct tagVARIANT const &)"...
0
by: Mike Cheel | last post by:
I keep getting that infernal LNK2005 error when I try to build my program. I am using VS.NET 2003. Here is the error: pm error LNK2005: "public: void __clrcall...
2
by: bosse | last post by:
Hi, i have got a linker problem, i don't know how to handle; there are three projects in my workspace. In the Project called modules_common is a class called Features. In the second project...
0
by: Taran | last post by:
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...
1
by: sethuganesh | last post by:
HI, i have ported vc++ 6.0 code to visual studio 2005. During batch build in debug mode i din't get any error.But if i build the same in release mode i am getting the following error. ...
1
nabh4u
by: nabh4u | last post by:
hi, i am getting a link error in my program which states that some variable which i declared in my header file is already defined in the object file. The error is like this: error LNK2005:...
1
by: dewi | last post by:
Dear All, I am trying to compile a C code using Visual C++. Can anyone explain how to solve it? Thank You. #include <math.h> #include <string.h> #include "RV2AJFRONT_NEW.h" #include...
9
by: dewi | last post by:
Dear All, I have several problem about VC++. I succeed to convert Simulink MATLAB to C code using Real-Time Workshop. I am trying to compile a C code using Visual C++ and found the error. Can...
1
by: patelcm22 | last post by:
Hi, I am facing following errors while building my application. Error 4 fatal error LNK1169: one or more multiply defined symbols found C:\Documents and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.