943,107 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3150
  • C++ RSS
Mar 15th, 2010
0

Error when linking: msvcprtd.lib(MSVCP90D.dll) : error LNK2005 ..... already defined

Expand Post »
Hello,
I am a totally newbie and I would be pleased, if you could help me.

Here is the problem: I have created VS 2008 project and configured it for using the ITK (toolkit for medical image analysis - in my case for reading Dicom images). Everything worked OK until I added ALGLIB to my project (library for algebraic operations - it is one file: libalglib.lib and a few .h files for include). Here comes the problem: when I tried to compile and link my project with this ALGLIB library, I got these errors and I dont know what to do (tried different Runtime library settings etc., nothing helped).

I assume, that it could be some conflict with ITK and ALGLIB - when I comment part of my code using ITK, everythnig works well (ALGLIB works ok) and when I comment part of my code using ALGLIB, everything works as well too (ITK works ok).

Here are the errors:

C++ Syntax (Toggle Plain Text)
  1. 1>Linking...
  2. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)"
  3. (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in libalglib.lib(trfac.obj)
  4. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)"
  5. (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in libalglib.lib(trfac.obj)
  6. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)"
  7. (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in libalglib.lib(trfac.obj)
  8. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const "
  9. (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in libalglib.lib(trfac.obj)
  10. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"
  11. (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in libalglib.lib(trfac.obj)
  12. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::erase(unsigned int,unsigned int)"
  13. (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z) already defined in libalglib.lib(trfac.obj)
  14. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::allocator<char>::allocator<char>(void)"
  15. (??0?$allocator@D@std@@QAE@XZ) already defined in libalglib.lib(trfac.obj)
  16. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::allocator<char>::deallocate(char *,unsigned int)"
  17. (?deallocate@?$allocator@D@std@@QAEXPADI@Z) already defined in libalglib.lib(trfac.obj)
  18. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::allocator<char>::allocator<char>(class std::allocator<char> const &)"
  19. (??0?$allocator@D@std@@QAE@ABV01@@Z) already defined in libalglib.lib(trfac.obj)
  20. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: char * __thiscall std::allocator<char>::allocate(unsigned int)"
  21. (?allocate@?$allocator@D@std@@QAEPADI@Z) already defined in libalglib.lib(trfac.obj)
  22. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: unsigned int __thiscall std::allocator<char>::max_size(void)const "
  23. (?max_size@?$allocator@D@std@@QBEIXZ) already defined in libalglib.lib(trfac.obj)
  24. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::assign(char const *)"
  25. (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@PBD@Z) already defined in libalglib.lib(trfac.obj)
  26. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::assign(char const *,unsigned int)"
  27. (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@PBDI@Z) already defined in libalglib.lib(trfac.obj)
  28. 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "protected: char * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Myptr(void)"
  29. (?_Myptr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEPADXZ) already defined in libalglib.lib(trfac.obj)
  30. 1> Creating library Debug\interpolating-scheme.lib and object Debug\interpolating-scheme.exp
  31. 1>Debug\interpolationg-scheme.exe : fatal error LNK1169: one or more multiply defined symbols found

Thanks for any HELP!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kosithc is offline Offline
9 posts
since Mar 2010
Mar 15th, 2010
0
Re: Error when linking: msvcprtd.lib(MSVCP90D.dll) : error LNK2005 ..... already defined
Are your headers vendor-supplied or self-written? Due to the multiple declaration issue, I'm wondering if they're not properly guarded.

Either that, or a couple of the errors make it look like there is an issue with namespaces. I see a couple errors that seem to be mentioning std::allocator(s) as a problem.

I'm afraid I can't help much beyond that though.
Featured Poster
Reputation Points: 833
Solved Threads: 392
Posting Maven
Fbody is offline Offline
2,846 posts
since Oct 2009
Mar 15th, 2010
0
Re: Error when linking: msvcprtd.lib(MSVCP90D.dll) : error LNK2005 ..... already defined
Thanks for reply!

Header files, which i include to my project, were provided with Alglib and ITK, so they are not self-made. I have only one header file with declaration of my one class.

I see it as well, that there could be some problem with namespace, any advice how to solve this?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kosithc is offline Offline
9 posts
since Mar 2010
Mar 15th, 2010
0
Re: Error when linking: msvcprtd.lib(MSVCP90D.dll) : error LNK2005 ..... already defined
Unfortunately, I do not know enough about namespaces to be of much help on that subject.

Maybe someone else can help better now that there is some direction to start heading down.

Let's doublecheck for header guards quick. If you open your headers, do you see lines similar to either of these?

C++ Syntax (Toggle Plain Text)
  1. //option 1, pragma:
  2. #pragma once
  3.  
  4. //or, option 2, macros
  5. #ifndef HEADER_NAME
  6. #define HEADER_NAME
  7.  
  8. /* ... code here ... */
  9.  
  10. //#endif
Last edited by Fbody; Mar 15th, 2010 at 11:37 am.
Featured Poster
Reputation Points: 833
Solved Threads: 392
Posting Maven
Fbody is offline Offline
2,846 posts
since Oct 2009
Mar 15th, 2010
0
Re: Error when linking: msvcprtd.lib(MSVCP90D.dll) : error LNK2005 ..... already defined
At a glance it looks as if the .dll is being included twice possibly under different names

as all the errors come from

MSVCP90D.dll
I am not sure how best to stop it though...

Click to Expand / Collapse  Quote originally posted by Kosithc ...
Thanks for reply!

Header files, which i include to my project, were provided with Alglib and ITK, so they are not self-made. I have only one header file with declaration of my one class.

I see it as well, that there could be some problem with namespace, any advice how to solve this?
Reputation Points: 32
Solved Threads: 37
Junior Poster
tetron is offline Offline
199 posts
since Feb 2010
Mar 15th, 2010
0
Re: Error when linking: msvcprtd.lib(MSVCP90D.dll) : error LNK2005 ..... already defined
If I open one, only mine, header, I dont have this:

option 2, macros
#
#ifndef HEADER_NAME
#
#define HEADER_NAME

I have there only include.

If i open headers provided with ITK or Alglib, there is ifndef, define...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kosithc is offline Offline
9 posts
since Mar 2010
Mar 15th, 2010
0
Re: Error when linking: msvcprtd.lib(MSVCP90D.dll) : error LNK2005 ..... already defined
How are you currently linking to both libraries?

Project settings etc...

Click to Expand / Collapse  Quote originally posted by Kosithc ...
If I open one, only mine, header,
This last statement is a bit confusing are you saying you have source code for alglib, itk ?
Reputation Points: 32
Solved Threads: 37
Junior Poster
tetron is offline Offline
199 posts
since Feb 2010
Mar 15th, 2010
0
Re: Error when linking: msvcprtd.lib(MSVCP90D.dll) : error LNK2005 ..... already defined
I have downloaded source code for both ITK and Alglib. Then I have followed the instructions for compiling it.
ITK - I have created a project for VS via Cmake, which configured all project properites for using ITK toolkit. Then I added in project (via add new item) library for Alglib - libalglib.lib. In tools I added in VC directories location of include files for all .h files, which alglib uses (these, which I created while compiling Alglib via user manual included in folder with Alglib).

I hope, I described it sufficiently.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kosithc is offline Offline
9 posts
since Mar 2010
Mar 16th, 2010
0
Re: Error when linking: msvcprtd.lib(MSVCP90D.dll) : error LNK2005 ..... already defined
I tried to change ITK, in hope, that ALGLIB will work with another library and oops, I used GDCM library (for reading dicoms) and there it is - same errors with libalglib.lib as with the ITK ;(
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kosithc is offline Offline
9 posts
since Mar 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: tarbo c 16 bit
Next Thread in C++ Forum Timeline: Pointer Trouble





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC