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

LNK 2001 errors in Visual Studio 2017 on an old code (2006)

Tudor_C_
Beginner
1,865 Views

Hi everyone,

I have an old code from 2006 which I want to compile on Visual Studio 2017. When I try to compile, a huge amount of LNK2001 errors are raised and after 5-6 minutes, Visual Studio uses all the RAM and crashes. I am in the debugging mode. I will paste down some of the errors :

ansys2.lib(mnf_writeCMS.obj) : error LNK2001: unresolved external symbol _MNF_SET_MODE_SHAPE_VEC
ansys2.lib(nt_xtbegn.obj) : error LNK2001: unresolved external symbol __imp__ShowWindow@8
ansys2.lib(MOD_Table.obj) : error LNK2001: unresolved external symbol __imp__sprintf
ansys1.lib(FEM_interp.obj) : error LNK2001: unresolved external symbol __imp___HUGE
ansys2.lib(nt_AnsCmdWnd.obj) : error LNK2001: unresolved external symbol __imp__GetStockObject@4
ansys2.lib(nt_ConPan.obj) : error LNK2001: unresolved external symbol __imp__DefWindowProcA@16
ansys1.lib(CSX_mesh.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(unsigned int,char)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ID@Z)
ansys2.lib(MAT_ExperimentalDataSet.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > & __thiscall std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::operator+=(unsigned short)" (__imp_??Y?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEAAV01@G@Z)

It is a huge amount of them. I will attach the build log.

I tried running on Debug MT and Debug MT DLL (and every other option there). I also tried to specify the libraries I used and select NODEFAULTLIB and also without NODEFAULTLIB. I checked many times that the directories where there are the libraries I use are correctly spelled. I don't have the code which creates the 2 libraries I am using (ansys1.lib and ansys2.lib) and I don't know how to access and edit the functions inside them if I would need to. Could it be a problem because of the old version of VS in which the code was written? 

Any piece of advice will help!
Thank you very much!

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
1,865 Views

You've got a lot going on there...

The _MNF... errors are looking for procedures in your own application.

The _HUGE reference is odd - maybe you have an EXTERNAL declaration for that? HUGE is an intrinsic in Fortran.

The functions with @n in the names are Windows API functions that should be resolved by linking to the appropriate Windows API libraries,

The last two you show in your post above seem to be coming from C++ code, though I've never seen them formatted like that.

View solution in original post

0 Kudos
3 Replies
Steve_Lionel
Honored Contributor III
1,866 Views

You've got a lot going on there...

The _MNF... errors are looking for procedures in your own application.

The _HUGE reference is odd - maybe you have an EXTERNAL declaration for that? HUGE is an intrinsic in Fortran.

The functions with @n in the names are Windows API functions that should be resolved by linking to the appropriate Windows API libraries,

The last two you show in your post above seem to be coming from C++ code, though I've never seen them formatted like that.

0 Kudos
Tudor_C_
Beginner
1,865 Views

Dear Steve

Thank you very much for your prompt reply and splitting my problems. Do you think that I might need to access and edit the .lib files or should I find a way to workaround? 

Best wishes,

Tudor

0 Kudos
mecej4
Honored Contributor III
1,865 Views

One of the reasons that the linking failed may be that you specified /NODEFAULTLIB:"msvcrt.lib", with no other CRT library specified in place of msvcrt.lib, either in the linker command or by INCLUDELIB directives in the objects and libraries involved in the linking.

If your ANSYS libraries were compiled with older versions of VC, there may be additional CRT incompatibilities between the ANSYS libraries and your newly compiled Fortran objects.

0 Kudos
Reply