Questions tagged [lnk2005]
117 questions
45
votes
18 answers
error LNK2005: new and delete already defined in LIBCMTD.lib(new.obj)
I have a Visual studio 2005 solution that has two projects. One is a static library and the other is a executable used to test the features in the static library. The static library uses MFC. I got the following errors when I built the solution.…
user59988
19
votes
1 answer
How to avoid "error LNK2005:" (already defined stdlib functions) when compiling libpng with Microsoft Visual Studio '08?
(Why I am trying to do this: I have had no luck in using the pre-built binaries for libpng on Windows (despite many hours of trial and error), and therefore am now trying to compile it myself. I found this helpful blog post concerning this, complete…

Sam
- 810
- 2
- 11
- 20
12
votes
1 answer
LNK2005 (already defined)
I know you've seen 21728517 people asking for help with this one but after searching and reading about this I really can't figure this one out. I know this error, I've seen it before, however, this time, I can't seem to get around it.
I've also…

takecare
- 1,684
- 3
- 21
- 32
10
votes
2 answers
standard library already defined in lib, causing linker error
Not sure what I'm doing wrong here, but say I have:
foo.h
class foo
{
public:
int Get10(std::wstring);
};
foo.cpp
int foo::Get10(std::wstring dir)
{
return 10;
};
And I compile it as a lib, if I include that lib in another project along with…

meds
- 21,699
- 37
- 163
- 314
9
votes
2 answers
Link error when declaring public static variables in C++
I have this class with variable configuration parameters. I want to include it in other classes: JugadorHumano, JugadorIA, Main, PartidaClasica, PartidaMision.
#pragma once
class Configuracion
{
public:
static int MAX_ATAQUES;
static int…

Zhertal
- 425
- 1
- 4
- 10
8
votes
3 answers
LNK 2005 in Visual C++ in Visual Studio 2010
I'm trying to compile a C++ program, written using Visual C++ 2005 and MFC, in MS VS 2010. Sadly I'm getting the following error during compilation:
Error 2 error LNK2005: "public: virtual __thiscall CMemDC::~CMemDC(void)" (??1CMemDC@@UAE@XZ)…

Andrey
- 83
- 1
- 1
- 3
7
votes
1 answer
Linking googleTest in VS2010 results in LNK2005 because of other dependent libraries
I have a large and complicated project that is finally getting unit tests. I've built googleTest 1.6.0 locally with Visual Studio 2010, the project files built with cmake as the README specifies.
This project has many dependent libraries that are…

Matthew Reddington
- 1,409
- 3
- 13
- 24
7
votes
1 answer
LNK 2005 error in Visual Studio 2005
I use Visual Studio 2005 on windows XP.
I'm trying to use "Google Test" framework. But i couldn't manage to make just one test because of linker errors.
I built Google Test source files with /MDd option in Debug mode
Than i created new project.
Then…

trante
- 33,518
- 47
- 192
- 272
6
votes
3 answers
LNK2005 Error linking static openCV libraries with Visual Studio and QT Creator
I built the static openCV 2.3 libraries. My project currently uses the dynamic ones with no problem, but now I want to use static libs. I added the libs to my .pro file:
LIBS += "C:\Program…

jzepeda
- 1,470
- 2
- 15
- 22
5
votes
2 answers
how to ignore LNK2005 & LNK1169?
So I have a Visual Studio 2010 project that uses external libraries and in order to get it compile without LNK2005 I had to juggle arround with the order of the libraries in the linker settings.
I got it to compile fine in release mode, but for…

Mat
- 63
- 1
- 1
- 5
4
votes
0 answers
How to deal with crates exporting symbols with identical names
I'd like to use both just-argon2 and sodiumoxide which are bindings to Argon2 and libsodium respectively. The first I will use for password hashing, the second for encryption and more.
However, because libsodium itself also includes the Argon2 code,…

SWdV
- 1,715
- 1
- 15
- 36
4
votes
1 answer
MSVC DLL exporting class that inherits from template cause LNK2005 already defined error
I've been tracking an error in a huge project for 3 days and finally get a minimum reproducable example. I want to share this problem and ask some questions on the weird behavior of Visual Studio.
When you export a class that inherits from a…

flm8620
- 1,411
- 11
- 15
4
votes
3 answers
VS 2010 C++ LNK2005 errors while using #pragma once and #ifndef
1>Deck.obj : error LNK2005: "class Card card" (?card@@3VCard@@A) already defined in Card.obj
1>PokerTester.obj : error LNK2005: "class Card card" (?card@@3VCard@@A) already defined in Card.obj
1>PokerTester.obj : error LNK2005: "class Deck deck"…

Shmoopy
- 632
- 5
- 15
3
votes
0 answers
Qt + Zlib => error LNK2005: _deflate_copyright already defined in QtCored.lib(deflate.obj) zlibstat.lib
When I link my application I receive the following message:
error LNK2005: _deflate_copyright already defined in QtCored.lib(deflate.obj) zlibstat.lib
I'm not sure of the problem, but... I use QT and ZLib. Both are "static libraries". The problem…

Spectral
- 717
- 2
- 12
- 28
3
votes
3 answers
MSVC 2010 linker error 2005 with std::cout in static library
I have found other examples of people having this problem but have had no luck with their solutions. I am trying to use std::cout in a static library that also uses boost threads and bind. When I don't use and std::cout it compiles and links fine…

contrapsych
- 1,919
- 4
- 29
- 44