Linking-Error with VSC++ 8.0

hey ho,
I just updated my project from VSC++ 7.1 to VSC++ 8.0 Express Edition. Unfortunately, i get a linker error every time i compile my project:

1>msvcprt.lib(MSVCP80.dll) : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" ( $ 6U $char_traits@D@std@@@std@@YAAAV $basic_ostream@DU $char_traits@D@std@@@0@AAV10@PBD@Z) already defined in main.obj
1>Release/test.exe : fatal error LNK1169: one or more multiply defined symbols found

With VSC++ 7.1 everything worked fine.

my Project is a static LIB (Multithread-DLL) and an EXE-File (Multithread-DLL) which links the LIB. The command-line for the EXE:

/OUT:"D:\Visual Studio Projects\test\Release\main.exe" /NOLOGO /MANIFEST /MANIFESTFILE:"Release\main.exe.intermediate.manifest" /NODEFAULTLIB:"libci.lib" /NODEFAULTLIB:"libcmt.lib" /ERRORREPORT:PROMPT ddraw.lib test.lib Psapi.lib wxmsw26_core.lib wxbase26.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib winmm.lib comctl32.lib rpcrt4.lib wsock32.lib oleacc.lib odbc32.lib d3d8.lib d3dx8.lib Twofish.lib dinput8.lib dxguid.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib

Can you help me

N00b


Answer this question

Linking-Error with VSC++ 8.0

  • tachikoma

    Thanks for your answers. Both /D_Secure_SCL=0 and /LTCG are already in use, the results I wrote before had that options already activated. I hadn't tried the different floating point options, though. The "improve floating point consistency" option of VC2003 was ignored when converting to a VC2005 project. I activated "fp:fast" for the release build and the project is finally back to the speed level of VC2003. Thank you very much for your patience.

    PGO isn't available to me, though, as I'm using VC8 Express Edition in private. I'll give it a try once it comes along by the msdn subscription of the company I'm working for.

    Bye, Thomas

  • Geze

    HI Thomas,

    So, what is the process to rebuild the "QT library"

    Thanks,

    Luba

    P.S. I am getting the same link error in VC 8.0


  • Joe Butler

    Thanks for your valuable feedback Thomas!
    First of all, I am glad you liked some of the features there.

    Here are some replies related to your concerns.

    Static" intellisense:
     It would be great if you help us improve such capability by actually emailing me or even logging bugs at our product feedback center.

    Executable speed:
    It could be due to the CRT methods using more secure approaches. Did you actually try using the new optimizations like Whole program optmization (/GL & /LTCG) & Profile guided analysis (PGO). These optmizations could really boost your performace. Nevertheless, I will be more than happy to investigate any case that you might find slower than VC7.

    VC Express:
    As you said, you need to compare the VS2003 Enterprise editions to at least the professional or the VSTS SKUs where more features are supported.

    Any ways, I really appreciate you taking the time to express your opinion. Please feel free to contact me any time if any help is needed from my side.

    Thanks,
    Ayman Shoukry
    Program Manager
    VC++ Team


  • Jeff Schindler

    Glad to hear that fp:fast bought back the lost perf. Thomas, someone from the VC team is currently investigating the linker errors you have been seeing and I will keep you updated.

    Thanks.
      Ayman Shoukry
      VC++ Team

  • BjarneSCN

    Hi there,

    I have a similar problem. I found this thread by using the "Ask a question" function in VC8. The situation is quite the same: moved a fairly large project from VS7.1 to VS8.0 (Express). The project consists of several libs, three executables and an external linked lib which was build in a separate solution. 
     
    All of the libs and executables were build with RT Multithreaded Debug DLL in Debug configurations and with Multithreaded DLL in Release configurations. The whole solution compiled fine in VC7.1 but throws some strange linker errors in VC8.0. Although they're somewhat lengthy I'll post them here in full detail. Maybe it helps to pin down the problem:

    ----------

    qtmaind.lib(qtmain_win.obj) : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<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 &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ( $ HDU $char_traits@D@std@@V $allocator@D@1@@std@@YA AV $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@0@ABV10@0@Z) already defined in msvcprtd.lib(MSVCP80D.dll)

    qtmaind.lib(qtmain_win.obj) : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(char const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ( $ HDU $char_traits@D@std@@V $allocator@D@1@@std@@YA AV $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@0@PBDABV10@@Z) already defined in msvcprtd.lib(MSVCP80D.dll)

    qtmaind.lib(qtmain_win.obj) : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<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 &,char const *)" ( $ HDU $char_traits@D@std@@V $allocator@D@1@@std@@YA AV $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@0@ABV10@PBD@Z) already defined in msvcprtd.lib(MSVCP80D.dll)

    qtmaind.lib(qtmain_win.obj) : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ( $ 6DU $char_traits@D@std@@V $allocator@D@1@@std@@YAAAV $basic_ostream@DU $char_traits@D@std@@@0@AAV10@ABV $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@0@@Z) already defined in msvcprtd.lib(MSVCP80D.dll)

    ------

    The last error is apparently the same is N00b's error above, the other three sound similar to me but it might as well be a completely different issue. I did an extensive search on google for a solution, only very few sites are found for the topic and most of them are talking about Runtime Library conflicts. So I already double checked the Runtimes in use. Anybody has a different idea how to solve this

    Thanks in advance.

    Bye, Thomas


  • Jetjez

    May I ask what were the main reasons for switching back to VC7 What were the main issues that were blocking the use of the Express SKU for you

    Please feel free to forward me the project to aymans at microsoft dot com and I can assign someone to look into the issue.
     
    Also, this previous post might help http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=75362&SiteID=1

    Thanks in advance for your feedback!

    Thanks,
    Ayman Shoukry
    Program Manager
    VC++ Team



  • DaveKoch

    Thanks Eugene for the great addition!

    Thomas already sent me a project reproducing the linker erros and we are looking into the issue. He is also going to contact me for any perf issues he might encounter.

    Thanks,
      Ayman Shoukry
      VC++ Team

  • Exellon

    The library in doubt was the QT library. It was neccessary to rebuild those libs with VC8 in order to get it linked properly. None of the VC8 runtimes libs had to be touched.

    Bye, Thomas


  • Laurel Hale

    Thanks for your reply. Mixed runtimes were my suspection as well but I wonder then why VC7 compiled it very well where VC8 finds double defined symbols. The "/verbose" switch you proposed produced large amounts of text but I didn't find additional information in it. Which two libs caused the conflict was already known from the original error message.

    I have reduced the project to a "small" stand alone example that demonstrates the error. Its only about 10 lines of code, but in order to compile it needs a large portion of the QT sources and headers. In addition I included the linker libs and DLLs we build from the QT sources, making the whole package 27MB heavy. I could remove some more sources but I'm not sure what exactly I have to keep in place in order to compile the project. It compresses to a handy 6.5MB archive, though. Please contact me at thomas@dreamworlds.de if you're interested in it.

    Don't feel in duty, though. After testing the express version for some days we finally decided to switch back to VC7 so it's not a cruical issue anymore.

    Bye, Thomas


  • Jon Limjap

    Thomas,

    In the case you want to investigate performance problems with VC8 executable:
    * please be sure that you turn off checks in the C++ library -- you may do that using /D_SECURE_SCL=0 in the command line;
    * you can try to statically link C run-time library -- when you are linking with DLL calls to functions such as memcpy() are done using extra indirection; on many CPUs that is slower than direct call, and for some pathological cases that overhead is very noticeable;
    * if your application is FP-heavy please use compiler flag /fp:fast.

    If you'll do all of that and your application is still slower than when compiled with VC7, we definitely will like to investigate the problem and will be grateful for the repro case; I understand that creating one and giving it to us will take your time, but there are good chances we'll be able to understand what is going on and maybe there is some easy source fix.

    Ayman gave you good advices about using advanced optimization options (Link-Time Code Generation and PGO). PGO is not supported in the express edition, but LTCG should be and you can give it a try.

    If you really care about performance you should try PGO -- for details look at http://msdn.microsoft.com/library/default.asp url=/library/en-us/dv_vstechart/html/profileguidedoptimization.asp.

    You may also find VC8 "__restrict" keyword very useful. For details look at the MSDN documentation, e.g. http://winfx.msdn.microsoft.com/library/default.asp url=/library/en-us/dv_vclang/html/2d151b4d-f930-49df-bd16-d8757ec7fa83.asp

    Thanks,
    Eugene


  • JDaniel

    Yes, of course. I'm happy to share some thoughts. Please consider the following to be my personal point of view after only a few days of testing. Other's opinions might differ.

    Pro V8:
    * Compiler works much faster
    * new Debugger features: 
    .. the "inline quickwatch" when pointing at a structure or object in the source
    .. the ability to show the contents of std classes in a readable way.
    * Intellisense improvements:
    .. does not crash occasionally on large projects
    .. does not bail out occasionally on large projects refusing to show anything until VC is restarted.
    .. does include system headers like e.g. DirectX
    .. does show global variables in namespaces.
    .. seems to handle template classes way better
    .. marks source that is not compiled due to preprocessor magic. Very helpful, especially when integrating third party source.

    Contra V8:
    * "Static" intellisense.

    Seems like the precise and more complete infos intellisense can offer now came with a price: most of the changes on a source or header arent detected until the next successful build or a VC restart. I switched to a header, corrected a typo in a member var, switched back to implementation and it took about half an hour till intellisense recognised the new name. Adding a new function prototype to a header and then trying to implement it is killing intellisense: you're typing all the stuff completely on your own. After restarting VC and letting Intellisense update its database I tried to continue implementing that function, but it kept switching between the correct scope and "(Global scope)" in intervals of about 20 seconds, unable to show any member function or variable of that class. Intellisense is one of the most important features of VC in my opinion. And despite all the cool new features the new intellisense is just too unreliable for my taste. Especially when you're trying to actually produce new code, not just edit existing code.

    Note: I left the function syntactically correct. I'm already used to always add a closing bracket as soon as I type an opening one and then inserting the actual content in the middle. It helps Intellisense2003 to keep track. It doesn't make any difference for Intellisense2005.

    * Executable speed.

    I haven't done any benchmark or anything else the audience might call "reliable". I just converted the project to VC8 and recompiled it. My personal statistic: Debug 14fps (vs 20 before), optimized Debug 50 fps (vs 90 in VC7), Release 90 fps (vs 115 before). As I said, the tests are not representative or valid for others, but they're important for me. At least the release configuration, the rest is a nice-to-have.

    I read the forums here and found some hints, adding defines to silence all the "deprecated" warnings I don't care for and trying to regain some of the speed. Yet to no avail. It might be a degraded compiler, though, much like the "student" version of VC7, where some optimisations were lacking. And I'm pretty sure with some time and a close look at all the new options there might be some further improvement in reach.

    * Some features lacking

    That's not a point exactly as I compare VC8 Express Edition against the full blown VS2003 Enterprise Edition my boss paid for me. I never used most of the stuff included there anyways. But there are some small details that indeed do hurt when they're missing: Macro support for example. I haven't found a detailed list what exactly the differences are between the express version and the larger ones so I can only guess what else I'll be missing then.

    In the end we decided to stay at VC7. We know what twists are needed to work around some of intellisense's problems, others we got used to. We're currently evaluating Visual Assist and if it proves to be useful it is as much of an improvement as I have ever hoped VC8 would bring.

    I hope you read this statement as a personal opinion. It's just a hint what I expected to find in the new version and it is in no way meant to be a general judgement. No offence intended.

    Bye, Thomas

  • 50322899

    Final update on the issue: Problem is solved thanks to the help the VC Compiler team.

    The data of the template functions has changed between VC2003 and VC2005 so the linker was unable to fold the data of both sources into one function. The solution is to rebuild the lib with VC2005.

    Thanks again to all of you.

    Bye, Thomas

  • Mark Watkin

    Hi Thomans,

    I am having the same Linking-error while trying to migrate a project from VC 7.1 to VC 8.0. You have mentioned above to rebuild the libs. Could you tell me which libs need to be rebuilt and what is the process to rebuild this library (If this library is some how related to VC 8 libraries).

    Thanks in advance.

    Regards,
    Prashanth Nethi.

  • kanlinkan

    The only guess is that you could be mixing different runtimes. I really can't say what might be happening without a stand alone sample to reproduce the issue. Try using the /verbose linker switch. This should dump where it is finding the symbols.

    Thanks,
      Ayman Shoukry
      VC++ Team

  • Linking-Error with VSC++ 8.0