Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29245 Discussions

LNK 2005 error linking static library - common item in MSVCRTD.lib(ti_inst.obj) and LIBCMTD.lib(typinfo.obj)

warwickb1
Beginner
4,393 Views

I get the following LNK2005 error messages relating to something in file MSVCRTD.lib(ti_inst.obj) being already defined in LIBCMTD.lib(typinfo.obj) when linking a static library file to a wrapper in Visual Studio 2012 Update 4:

  • Error    1     error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)    [File:   MSVCRTD.lib(ti_inst.obj)    ]
  • Error    2     error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)    [File:  MSVCRTD.lib(ti_inst.obj)    ]
  • Warning    3     warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library    [File: LINK    ]

I have started to modify my program to enhance its capabilities.  However, an error has occurred in the existing version so that
I have had to re-build it so that I can debug it.  It creates a static library.  This is the error I get when I try to link it with the wrapper program that runs it.  I can't find much on this subject via an Internet search other than the question of what to do about it.  Could it have something to do with the new version of the compiler (Fortran 15)?  The wrapper's link properties already specify to

                     Ignore Specific Library: libcmt

If I add libcmtd to the list of libraries to ignore and re-build, I still get the same messages!!  Quite disappointing!  Similarly for MSVCRTD.

If I specify to ignore all default libraries, as seems to be suggested in the Warning, many errors emerge.

It looks like something has changed, presumably in the build of my library, but I can't see what it is.  The same error messages occur if I make the change to "Ignore" MSVCRTD" in building the static library.    If I also "Ignore "MSVCRTD" in building the wrapper I get more error messages - this time relating to LIBCMTD.lib (in file libcmt.lib(invarg.obj)).

Hope someone else has had this issue before and can suggest something to try!

Warwick

0 Kudos
4 Replies
Steven_L_Intel1
Employee
4,393 Views

This is "mixed C library syndrome". Make sure that all projects in your solution are compiled with the same setting for run-time libraries. In Fortran this is under Libraries, in C++ it's in Code Generation. Rebuild everything.

0 Kudos
warwickb1
Beginner
4,393 Views

Hi.

I have this issue again for DEBUG.    RELEASE is OK.  I initially ran into this problem using VS2013 so reverted to using VS2012.  I got Debug working that way, but now it fails.  I accidentally changed the version that worked while trying to get a new version of one of the libraries built in VS2012 for testing.  However, the Release version builds.

I am linking 4 library files.  One is required for the ForDBCTM ODBC subroutines.  This requires libcmt to be declared in the ‘Ignore Specific Library’ list – which it is in.  Additional dependencies are provided as

                        odbc32.lib advapi32.lib IpHlpApi.lib

I don’t know how the ForDBC library was built. 

My libraries were built using Canaimasoft’s f90SQLTM.  These require external procedures to be CVF with ‘After Individual String Argument’.  They also require the f90SQL.lib library.

If I omit

  • calls to my own subroutines and
  • their libraries

from the build then DEBUG will also not build, giving errors such as

Description

File

Error    2          error LNK2005: "void __cdecl _invoke_watson(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invoke_watson@@YAXPBG00II@Z) already defined in LIBCMTD.lib(invarg.obj)                   

LIBCMT.lib(invarg.obj)

Error      3              error LNK2005: __call_reportfault already defined in LIBCMTD.lib(invarg.obj)               

LIBCMT.lib(invarg.obj)

Error      4              error LNK2005: __get_invalid_parameter_handler already defined in LIBCMTD.lib(invarg.obj)         

LIBCMT.lib(invarg.obj)

Warning           10        warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library                       

LINK

Error    11        fatal error LNK1169: one or more multiply defined symbols found

Debug\Iris.exe 

 

For DEBUG, with calls to my own DEBUG libraries included in the build (no DEBUG library for the ForDBC library) then I get similar errors and a couple more –

Description

File

Error    10        error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)     

MSVCRTD.lib(ti_inst.obj)           

 

Error    11        error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)     

MSVCRTD.lib(ti_inst.obj)

Warning           12        warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library           

LINK  

Warning           13        warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library                       

LINK

Error    14        fatal error LNK1169: one or more multiply defined symbols found

Debug\Iris.exe

 

For RELEASE, if I call my subroutines and include my libraries in the build,, then the build succeeds.

If for RELEASE I do not call my subroutines and

  • only have the ForDBC library OR
  • the ForDBC library and my own RELEASE libraries

in the build, then I get a multitude of errors such as

Description

File

Error    1          error LNK2001: unresolved external symbol __fltused        

libifcoremt.lib(for_m_irand.obj)         

Error    2          error LNK2001: unresolved external symbol __fltused            svml_dispmt.lib(svml_s_expf4_maskcore_a6la.obj)

svml_dispmt.lib(svml_s_expf4_maskcore_a6la.obj)

Error    297      error LNK2019: unresolved external symbol __except_list referenced in function _tbk_trace_stack_impl

libirc.lib(tbk_backtrace.obj)

Error    298      error LNK2019: unresolved external symbol __time64 referenced in function _SEED        

libifcoremt.lib(for_m_irand.obj)         

Error    299      error LNK2001: unresolved external symbol __load_config_used   

LINK  

Error    300      fatal error LNK1120: 82 unresolved externals         

Release\Iris.exe           

 

I am hopelessly puzzled.  Hope you have some ideas as to how I might get Debug working again without having to try to find the minimal instance that fails!

Warwick

0 Kudos
warwickb1
Beginner
4,393 Views

The problem seems to have been solved.

The ODBC routine set of QT Software's ForDBC (Release) requires LibCmt to be ignored by the linker - QT Software do not mention excluding LibCmtD for debug.  A colleague explained that Debug libraries have the 'd' added to their names and said that I could put both into the build statement so that it would work for either case (Release or Debug).  Thus, for the Debug version I specified both LibCmt and LibCmtD:

Configuration Properties > Linker > Input > Ignore Specific Library > LibCmt LibCmtD

When I changed this for the Debug case to

Configuration Properties > Linker > Input > Ignore Specific Library > LibCmtD

the build succeeded except for the warning message about MSVCRTD.  So I included that in the list and there were no warnings or errors:

Configuration Properties > Linker > Input > Ignore Specific Library > LibCmtD MSVCRTD

Once again I can build my CanaimaSoft-using ODBC routines (f90SQL) with the new ForDBC-using wrapper that runs it, whereas I was going to try converting all my libraries to use ForDBC.  That still wouldn't have fixed the problem, so thankfully the idea of excluding LibCmt came sooner.

I must confess not understanding why I cannot exclude both for Debug when LibCmt is to be ignored for the Release build.

0 Kudos
Steven_L_Intel1
Employee
4,393 Views

The instructions for "Ignore specific library" say to separate library names with semicolons.

0 Kudos
Reply