Link to home
Start Free TrialLog in
Avatar of vileda
vileda

asked on

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


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?
ASKER CERTIFIED SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of phoffric
phoffric

Do you have the source code so that you can compile it along with the rest of your project?
>> The error is a multiply defined symbol located in OpcServer.obj.

Note that the symbol is ~basic_string, suggesting mixed CRT
Avatar of vileda

ASKER

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.
>> 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.
Avatar of vileda

ASKER

closed