Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Composer XE (12.0.2) libcmt being linked by libmatmul

AndrewC
New Contributor III
605 Views
I have am transitioning my Visual Studio 2008 projects from Compiler 11.1 (067) to Composer XE (12.0.2).

A problem is that when I link the "Release/x64" build of my DLL I get the following error due to libcmt.lib being introduced into the link somehow.

>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>MSVCRT.lib(cinitexe.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libcmt.lib(crt0.obj) : error LNK2019: unresolved external symbol main referenced in function __tmainCRTStartup


And I found what was causing the issue

One of my projects was being compiled /O3 /Qparallel. If you read the "fine print" this automatically invokes /Qopt-matmul

Searching E:\\Program Files (x86)\\Intel\\ComposerXE-2011\\compiler\\lib\\intel64\\libmatmul.lib

If you do a
dumpbin /DIRECTIVES of libmatmul.lib above you see


Linker Directives
-----------------
-defaultlib:"libiomp5md"
-defaultlib:"libmmt"
-defaultlib:"LIBCMT" <-------------- ERROR
-defaultlib:"libirc"
-defaultlib:"svml_disp"
-defaultlib:"OLDNAMES"
-defaultlib:"libdecimal"

Note : sample project attached. Requires VS 2008 and Composer X3E 12.0.2
Build X64/Release configuration
0 Kudos
7 Replies
TimP
Honored Contributor III
605 Views
If you know that you don't want the library MATMUL, you could turn off opt-matmul. This might be the right course anyway if your matrices aren't large, like 30x100.
Does the /nodefaultlib:libcmt.lib work, in case you do want the opt-matmul?
0 Kudos
AndrewC
New Contributor III
605 Views
I can turn off the option manually once I knew what the issue was.

But the points are
  • This is a pretty subtle hidden change and quite a trap to fall into. I think /O3 and /Qparallel should not "automatically" turn on another option.
  • It occupied me for the better part of a day to diagnose the issue. It is actually very difficult to track down which dependent library forces libcmt to be included.
  • the "matmul" option is not well documented
  • There clearly is a bug in that there needs to be a libmatmulMD.lib and libmatmulMDd.lib for when /MD and /MDd are set in the compiler options.
0 Kudos
Om_S_Intel
Employee
605 Views
I think depedancy checker would help in finding the dependant modules. I do not think debug version of libray would help.
0 Kudos
AndrewC
New Contributor III
605 Views
Dependency checker ( do you mean dependency walker) works with .DLL and .EXE. It is of no us in this situation.
The Intel Compiler and build system is automatically linking in libmatmul.lib. libmatmul.lib has been linked against libcmt.lib. This is a bug in the build system
0 Kudos
JenniferJ
Moderator
605 Views
Hi vasci_intel,
I agree that it's a bug in building the libmatmul.lib. The "libcmt.lib" should not be linked in because /MD is used. I'll file a bug report about this.

Although changing /O3 to /O2worked around the issue,because the libmatmul.lib is not linked in. But "/nodefaultlib:libcmt" worked for me.

thanks for letting us know and also thanks for providing a testcase.

Jennifer
0 Kudos
JenniferJ
Moderator
605 Views
Hello,
This bug has been fixed in Update 9 at least. The latest update is update 10 right now.

thanks,
Jennifer
0 Kudos
junziyang
Beginner
605 Views
I'm fraid the problem still exist for the Fortran Compiler.
When I try to compile with the /Qopt-matmul I got the following error:
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
MSVCRT.lib(cinitexe.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
libifcoremd.lib(for_main.obj) : error LNK2019: unresolved external symbol _MAIN__ referenced in function _main
pdesolverLW.mexw32 : fatal error LNK1120: 1 unresolved externals
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:libraryMSVCRT.lib(cinitexe.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:librarylibifcoremd.lib(for_main.obj) : error LNK2019: unresolved external symbol _MAIN__ referenced in function _mainpdesolverLW.mexw32 : fatal error LNK1120: 1 unresolved externals
0 Kudos
Reply