User forums > Using Code::Blocks

Codeblocks 12.11 LNK2005 errors using VS 2010

<< < (4/4)

Biplab:

--- Quote from: Mug on February 26, 2013, 10:10:54 am ---That was terribly simple after all the frustration I've had over the last few days.

--- End quote ---
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.


--- Quote from: Mug on February 26, 2013, 10:10:54 am ---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?

--- End quote ---
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>
--- End code ---


--- Quote from: Mug on February 26, 2013, 10:10:54 am ---Is there any way I can check if the static libraries are there?

--- End quote ---
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>
--- End code ---
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.

Mug:
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.

Biplab:

--- Quote from: Mug 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.

--- End quote ---

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.

Navigation

[0] Message Index

[*] Previous page

Go to full version