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

Linking error when using static library from VC++

Mengtao_Yuan
Beginner
2,424 Views
I used IVF to compile a static library ifor.lib. My VC++ project(Visual studio 2008)in a different solution calls functions in ifor.lib. However, when I ambuilding the VC++ projectthere islink error:

LINK : fatal error LNK1104: cannot open file 'ifconsol.lib'

When I changed the property "Disable Default Library Search Rules" to YES in my IVF project and recompile my VC++ project, I got different link error:

2>ifor.lib(a.obj) : error LNK2001: unresolved external symbol _for_cpstr
...

2>ifor.lib(b.obj) : error LNK2001: unresolved external symbol _for_write_seq_fmt

...

How to solve this Link problem?

0 Kudos
5 Replies
Mengtao_Yuan
Beginner
2,424 Views
Any suggestions on this problem. I thought it might be a common problem when C++ code calls .lib files compiled by IVF compiler.
0 Kudos
TimP
Honored Contributor III
2,424 Views
For Visual Studio, it should be sufficient to use ifort to drive link. If you did it some other way, you're failing to search a needed library, such as libifcoremt.lib.
0 Kudos
Mengtao_Yuan
Beginner
2,424 Views
Quoting tim18
For Visual Studio, it should be sufficient to use ifort to drive link. If you did it some other way, you're failing to search a needed library, such as libifcoremt.lib.

I cannot use ifort to drive link. The purposeof my usingIVF is to generate a stand-alone library so that it can be called from C++ projects, without introducing IVF in the C++ code development.
0 Kudos
Mengtao_Yuan
Beginner
2,424 Views
Another approache I tried is to change the property of C++ project following the instructions from the link:

http://software.intel.com/en-us/articles/configuring-visual-studio-for-mixed-language-applications


However, I got other link errors:

2>LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj)

2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj)

2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj)

2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj)

2>LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj)

2>LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(errmode.obj) : error LNK2005: ___set_app_type already defined in MSVCRTD.lib(MSVCR90D.dll

0 Kudos
Mengtao_Yuan
Beginner
2,424 Views
Quoting Mengtao Yuan
Another approache I tried is to change the property of C++ project following the instructions from the link:

http://software.intel.com/en-us/articles/configuring-visual-studio-for-mixed-language-applications


However, I got other link errors:

2>LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj)

2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj)

2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj)

2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj)

2>LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj)

2>LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR90D.dll)

2>LIBCMT.lib(errmode.obj) : error LNK2005: ___set_app_type already defined in MSVCRTD.lib(MSVCR90D.dll

Solved problem above. It is MKL related because I am calling multithread MKL.
http://software.intel.com/en-us/forums/showthread.php?t=56041

To remove the link errors, basically I have to:
1. In Fortran Lib project, set "Disable Default Library Search Rules" to "No"
2. In C++ main project, add $(IFORT_COMPILER11)lib\ia32 in Tools > Options > Projects and Solutions > VC++ Directories > Library files.

0 Kudos
Reply