Solved

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

Posted on 2010-09-22
7
562 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now