Author Topic: Codeblocks 12.11 LNK2005 errors using VS 2010  (Read 22083 times)

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Codeblocks 12.11 LNK2005 errors using VS 2010
« Reply #15 on: February 26, 2013, 01:09:49 pm »
That was terribly simple after all the frustration I've had over the last few days.
Now you know that wizard shows that message for a reason. As long as you don't mix & match CRT, you should not see these errors.

For the time being, that will certainly get me started, but, if I dare ask, what steps do I need to take to use static CRT mode?
To build wxwidgets with static CRT, you need to do the following. In Visual Studio click Project -> Properties -> Configuration Properties -> C/C++ -> Runtime Library & select Multi-threaded/Multi-threaded Debug option. Click OK to close dialog. Do this for all projects.

Alternatively in the command prompt add the following to compile it with static CRT.
Code
nmake /f makefile.vc RUNTIME_LIBS=static <Other Options>

Is there any way I can check if the static libraries are there?
You can check it by issuing following command
Code
D:\Projects\Test1\Debug>dumpbin /all Test1.lib | find /i "/DEFAULTLIB"
  00000000: 20 20 20 2F 44 45 46 41 55 4C 54 4C 49 42 3A 22     /DEFAULTLIB:"
   /DEFAULTLIB:MSVCRTD
   /DEFAULTLIB:OLDNAMES

D:\Projects\Test1\Debug>
As you can see this shows static library Test1.lib is dynamically linked against MSVCRTD.lib. In this case if you want to link any app against Test1.lib you have to use /MTd as compiler and linker option.

When Test1.lib is linked against static MSVC runtime, it will show libcmt[d].lib in output.
Be a part of the solution, not a part of the problem.

Offline Mug

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Codeblocks 12.11 LNK2005 errors using VS 2010
« Reply #16 on: February 26, 2013, 02:09:57 pm »
Biplab, thank you very much for your very informative and helpful information. Now I understand everything much better.

I think it's best not to start messing with compiler settings now everything is working, at least for the time being. You have been most helpful and I'm extremely greatful to you. At last I can start concentrating on what I originally set out to do, and that is learning how to use wxWidgets. I had almost given up on code::blocks.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Codeblocks 12.11 LNK2005 errors using VS 2010
« Reply #17 on: February 26, 2013, 02:25:58 pm »
Biplab, thank you very much for your very informative and helpful information. Now I understand everything much better.

I think it's best not to start messing with compiler settings now everything is working, at least for the time being. You have been most helpful and I'm extremely greatful to you. At last I can start concentrating on what I originally set out to do, and that is learning how to use wxWidgets. I had almost given up on code::blocks.

You're most welcome. Enjoy Code::Blocks. :)

For future problems, try to post as much information as possible. That helps others debug the issue easily.
Be a part of the solution, not a part of the problem.