Solved

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

Posted on 2010-09-22
7
574 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.

739 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