Solved

linker error ".... already defined in xxxx"

Posted on 2010-09-22
7
573 Views
Last Modified: 2012-05-10

Hello,

I'm trying to compile a program but it gives an error like below:

Executing: ""C:\Rhapsody752\Share"\etc\msvc9make.bat deneme.mak build "
Setting environment for using Microsoft Visual Studio 2008 x86 tools.
The filename, directory name, or volume label syntax is incorrect.
Building library deneme.dll msvcprt.lib(MSVCP90.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)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in OpcServer.obj

I added OpcServer.obj from another project. What's the problem here?
Could you help me please?
0
Comment
Question by:vileda
  • 3
  • 2
  • 2
7 Comments
 
LVL 40

Accepted Solution

by:
evilrix earned 250 total points
ID: 33734286
My first thought would be that you are trying to link to an object file that was build using a different version of the C Runtime.
http://msdn.microsoft.com/en-us/library/abx4dbyh(VS.80).aspx

You need to ensure all objects are build using the same runtime.
0
 
LVL 32

Assisted Solution

by:phoffric
phoffric earned 250 total points
ID: 33734358
The error is a multiply defined symbol located in OpcServer.obj.
Here are some suggestions on resolving this error:
     http://msdn.microsoft.com/en-us/library/72zdcz6f%28VS.80%29.aspx
0
 
LVL 32

Expert Comment

by:phoffric
ID: 33734383
Do you have the source code so that you can compile it along with the rest of your project?
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 40

Expert Comment

by:evilrix
ID: 33734745
>> The error is a multiply defined symbol located in OpcServer.obj.

Note that the symbol is ~basic_string, suggesting mixed CRT
0
 

Author Comment

by:vileda
ID: 33741439
I compiled my main program with /MT option and my libray OPCServer.obj with /MD option.  I don't have any idea about how it worked but It worked.
0
 
LVL 40

Expert Comment

by:evilrix
ID: 33741893
>> I don't have any idea about how it worked but It worked.

are you saying that resolve it? I suspect that it's not really since you are still using two different C runtimes.

MT: Multithreaded, static link
MD: Multithreaded, dynamic link (import library for MSVCR80.DLL). Be aware that if you use the Standard C++ Library, your program will need MSVCP80.DLL to run.

You should should the same C runtime otherwise you will (potentially) get undefined behaviour.
0
 

Author Closing Comment

by:vileda
ID: 33768648
closed
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Arduino EDI - Programming language 3 104
Dialogbox API leak? 18 99
White board coding practice 3 92
learn programming 8 42
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question