473,626 Members | 3,369 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LNK2005 error in visual c++ (already defined in .obj)

nabh4u
62 New Member
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: "struct list * first" (?first@@3PAUmy list@@A) already defined in list.obj
error LNK2005: "struct list * last" (?first@@3PAUmy list@@A) already defined in list.obj
error LNK2005: "struct list * current" (?first@@3PAUmy list@@A) already defined in list.obj


this is the declaration i am using in myheader file:

Expand|Select|Wrap|Line Numbers
  1. #ifndef LIST_H
  2. #define LIST_H
  3. # include<iostream>
  4. # include<list>
  5. # include<vector>
  6.  
  7. struct list
  8. {
  9.     int number;
  10.     list *previous;
  11.     list *next;
  12. };
  13.  
  14. vector <list *> listpointer; // Vector having the pointer to the elements of the list.
  15.  
  16. list *first; //  is the head of the list.
  17. list *last; // store the last position of the list.
  18. list *current; // for maintiaining the current position
  19.  
  20. void add_first();
  21.  
  22. #endif
what is wrong with the declaration? how can i correct it? I have to use these variables in my cpp file.
Mar 8 '07 #1
1 11960
willakawill
1,646 Top Contributor
Hi. Perhaps if you remove the #include <list>
Mar 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4690
by: Jon | last post by:
Hi! I have a problem that have followed me for a long time. When linking, sometimes this link error below arises. My solution is always to remove all files in the project, throw away all debug-files (.obj), rebuild, insert all files in the project and rebuild. After that procedure, the linker usually proceed. But not this time. So I decided to try and find the real problem, but failed. So here I am. When Linking in debug-mode, this...
1
4031
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 &)" (??0COleDateTime@ATL@@QAE@ABUtagVARIANT@@@Z) already defined in atlsd.lib(ATLComTime.obj) atlsd.lib(ATLComTime.obj) : error LNK2005: "public: void __thiscall ATL::COleDateTime::SetStatus(enum ATL::COleDateTime::DateTimeStatus)"
2
2399
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 there's a class called FeaturesFromPng, which contains an instance of Features. The third project contains the main-function in which i want to work with an instance of FeaturesFromPng, but generating the instance produces a LNK2005 error. If i...
0
507
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 "iof_config.h" file. //**************************************************** //FILE : iof_library.h //****************************************************
1
7897
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. LIBCMT.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in atlmincrt.lib(atlinit.obj) LIBCMT.lib(tidtable.obj) : error LNK2005: __encoded_null already defined in atlmincrt.lib(atlinit.obj)
6
9828
by: fcvcnet | last post by:
Hi all, I defined a class, as fellows: // Segment.h #pragma once #include "MyPoint.h" enum TLSC {PARALLEL, INTERSECT, COINSIDE,INTERSECTATDIASTOLE} twolinesolutioncases;
1
5725
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 "RV2AJFRONT_NEW_private.h"
9
3207
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 anyone explain how to solve it? --------------------Configuration: PROJECT2 - Win32 Debug-------------------- Linking... RV2AJFRONT_NEW.obj : error LNK2005: _rtM_RV2AJFRONT_NEW already defined in RV2AJFRONT_NEW.obj RV2AJFRONT_NEW.obj : error...
1
2305
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 Settings\chirag.patel\Desktop\Game\GameTest\Debug\GameTest.exe 1 Error 2 error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj) uafxcwd.lib Error 3 error LNK2005: "void * __cdecl operator new(unsigned int)"...
0
8265
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7193
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.