Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

What do I do about "error LNK2011"?

LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in Insure++
The short answer: turn pch off.

The warning:
Some projects fail to build when you turn pch off.

The longer answer:
One can not mix the use of instrumented and uninstrumented precompiled headers in the compilations of object files destined to become part of a single executable. If instrumented and uninstrumented precompiled headers are used, the link may or may not succeed. This is due to a limitation of the compiler/linker. Microsoft does not specifiy under what conditions this link error is given. I know that trivial test cases usually link just fine, but larger projects have been known to fail.

This means that every single object in the project must be successfully instrumented for the link to succeed.

Some may protest, "But I am instrumenting the entire project!"

There is a psrc-option, "compiler_fault_recovery" that controls Insure++ behavior regarding problems encountered during instrumentation. It is on by default, and if you are hitting LNK2011, it likely means insure++ is fault recovering when instrumenting some object in your project.

See also the FAQ titled "My project doesn't build when pch is turned off".

The reason for the link error is documented internally as PR43847.