Win32 -MD link error

Win32 -MD link error

I get link error with -MD option when I use an STL class
with pre-defined static data. A plain "hello" program
won't link with -MD option. It links fine with -MT or -ML,
but produces a much bigger executable.

Furthermore, obj files compiles with -MD option is much
bigger than ones produced by plain CL. It looks like ICL
instantiates what are already contained in MSVCP71.DLL

configuration:
Windows XP Build 2600.xpsp2.030422-1633: SP1
Visual Studio .Net 2003 v7.1.3088
Intel C++ Compiler 7.1.005

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Adding "-Zc:wchar_t" can work around unresolved
external to basic_istream::'vftable' and
basic_istream::'vbtable', but if you
include a header (for C++ toupper() function),
you get unresolved external to
bool moneypunct::intl.

This is quite annoying because I think those variables
are certainly the DLL. It looks like ICL forget to prepend
__imp_ to their names. (Are there any tools to edit OBJ
files?)

> Adding "-Zc:wchar_t" can work around unresolved
> external ...

That works in limited cases. But if any of the /Z7, /Od, or /Ob0 switches are used with /MD or /MDd, other linker errors surface.

From here, this looks like a showstopper as far as using 7.1 with VC++ 7.1 goes:-(

--Beman Dawes

If you are referring to an error like this:

error LNK2019: unresolved external symbol "const basic_ostream>::`vftable'" (??_7?$basic_ostream@H@@6B@) referenced in function "public: virtu
al __thiscall basic_ostream::~basic_ostream(void)" (??1?$basic_ostream
@H@@UAE@XZ)

it has recently been fixed and should be available in a compiler soon. If you would like to be notified when the fix is available you can enter a Premier Support issue and we will let you know.

Thanks!
Lerie
Intel Compiler Support

I found workaround of this problem. It uses undocumented MS linker switch /alternatename. This switch can be added e.g into source code via #pragma comment(linker, "...").

#include
#include
#include

#pragma comment(linker, "/alternatename:??_7?$basic_istream@GU?$char_traits@G@std@@@std@@6B@=__imp_??_7?$basic_istream@GU?$char_traits@G@std@@@std@@6B@")
#pragma comment(linker, "/alternatename:??_7?$basic_ostream@GU?$char_traits@G@std@@@std@@6B@=__imp_??_7?$basic_ostream@GU?$char_traits@G@std@@@std@@6B@")
#pragma comment(linker, "/alternatename:??_8?$basic_istream@GU?$char_traits@G@std@@@std@@7B@=__imp_??_8?$basic_istream@GU?$char_traits@G@std@@@std@@7B@")
#pragma comment(linker, "/alternatename:??_8?$basic_ostream@GU?$char_traits@G@std@@@std@@7B@=__imp_??_8?$basic_ostream@GU?$char_traits@G@std@@@std@@7B@")

Very nice one. Thanks.

Leave a Comment

Please sign in to add a comment. Not a member? Join today