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

Intel Classic Fortran Compiler & statically linked MFC targeting VC11 Toolset

Andrew20
Beginner
838 Views

Using visual studio 2022 and the Intel Fortran Compiler Classic 2023.2.1, I created a new vc++ project that targets the vc11 (visual studio 2012) platform toolset. To my solution, i also added a new Fortran library project which i then linked to my vc++ project by:

  • Specifying the directory containing my fortran library in Linker > General > Additional Library Directories
  • Adding the library to Additional Dependencies

 

VCC directories:

  • [include] $(IFORT_COMPILER23)compile\include;
  • [library] ($IFORT_COMPILER23)compiler\lib\ia32_win; (and Intel64) when building 64 bit

 

With these settings:

  • Use of MFC = Use MFC in a Shared DLL  [vc++ proj setting]
  • Runtime Library = Multi-Threaded Debug DLL [vc++ proj setting]
  •  Debug Multithread DLL [IFORT proj setting]

The Win32 debug build works fine. 

If attempt to statically link MFC by changing:

  • Use of MFC = Use MFC in a Static Library [vc++ proj setting]
  • Runtime Library = Multi-Threaded Debug [vc++ proj setting]
  • IFORT Runtime Library = Debug Multithreaded [IFORT proj setting]

I get a number of linker errors, such as:

  • Error LNK2001 unresolved external symbol ___acrt_iob_func TestApp [...]\TestApp\libifcoremt.lib(for_diags_intel.obj) 1
  • Severity Code Description Project File Line Suppression State
    unresolved external symbol ___stdio_common_vfprintf TestApp [...]\TestApp\libifcoremt.lib(for_diags_intel.obj) 1
  • [...]TestApp\TestApp\libifcoremt.lib(for_diags_intel.obj) 1

The same behaviour is observed when attempting to build the 64-bit version of the libraries, when statically linking. 

I have tried adding /Qvc11 to the Fortran >> Command Line additional options in the fortran project.  

I believe the unresolved external symbols are due to functions being removed from the universal CRT, which now reside in legacy_stdio_definitions.lib but as i am compiling against the VC11 platform toolset, I don't think i can include this library. 

 

The project does build when i statically link and change the VC++ project to target the following toolsets:

  • Visual Studio 2022 (V143)
  • Visual Studio 2019 (V142)
  • Visual Studio 2017 (V141)
  • Visual Studio 2015 (V140)

Unfortunately, my project cannot be upgraded to a newer platform toolset at this time due to a heavily ingrained dependency. We currently build using Parallel Studio XE 2017. 

 

I have attached a simple demonstration of the problem. 

 

0 Kudos
2 Replies
Andrew20
Beginner
779 Views

I have been able to work around the problem by copying certain libraries from the Parallel Studio XE 2017 installation on another machine into the OneAPI installation, for example:

  • libifcore.lib
  • libifcoremt.lib
  • libirc.lib
  • libircmt.lib
  • libmmt.lib

 

JohnNichols
Valued Contributor III
768 Views

I have attempted with the latest VS 2022 Preview and oneapi to compile your program.  Once I fixed the target SDK - yours is very old and out of support, it asks for mylib.lib - how do you want me to link in the library that is in your system

 

0 Kudos
Reply