Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

LINKING ERROR (error LNK2019) during VC++ project Build with Fortran Dependencies

$
0
0

Hi.
I have and issue building the C++ DLL and Intel Visual Fortran. The C++ project code has reference to a subroutine defined in Fortran file (*.for) for certain mathematical analysis and modeling.

Background:
We have a mathematical modelling legacy application built using C++ COM(VS6.0) and Fortran (Compaq Visual fortran ). I am in the process of migrating the code base in Visual Studio 2013 and Intel Visual Fortran - 2016.

Migration Procedure followed:
These were the steps I followed to migrate the C++ and Fortran environment as per the various post I could read from this forum.

  1. Open the VC6.0 Workspace file in VS2013
  2. Converted the project by VS2013 default conversion method.
  3. Rightclick on solution and choose "Extract Compaq Visual Fortran Project Items"
  4. A new Project with the solution was created named LFA_lib_
  5. Build the Fortran project ( LFA_lib_ ) which was newly created. Build was successfull with a .lib and .obj file in the .\Debug Folder.
  6. Added LFA_lib_.lib file as a dependency to the main project (C++ project) ( Right Click LFA Project(C++)-> Linker -> Additional Dependencies -> .\Debug\LFA_lib_.lib)
  7. On Compilation the C++ project, this complies but on linking gives the error LNK2019.( Build information included below)
  8. On commenting the function MMODELCURFIT reference with my C++ code the build is perfect without any errors and warnings.

Build Log File:
Including the Build Log File for details.

==============================================================================
Build started 22-09-2015 16:08:15.
1>Project "D:\FLOWSERVE\Server\Components\LFA\LFA.vcxproj" on node 2 (Rebuild target(s)).
1>Midl:
 C:\Program Files (x86)\Windows Kits\8.1\bin\x86\midl.exe /W1 /nologo /char signed /env win32 /Oicf /h "LFA.h" /iid "LFA_i.c" /tlb ".\LFA.tlb" LFA.idl
 Processing .\LFA.idl
 LFA.idl
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\um\oaidl.idl
 oaidl.idl
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\um\objidl.idl
 objidl.idl
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\um\unknwn.idl
 unknwn.idl
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\shared\wtypes.idl
 wtypes.idl
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\shared\wtypesbase.idl
 wtypesbase.idl
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\shared\basetsd.h
 basetsd.h
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\shared\guiddef.h
 guiddef.h
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\um\ocidl.idl
 ocidl.idl
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\um\oleidl.idl
 oleidl.idl
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\um\servprov.idl
 servprov.idl
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\um\urlmon.idl
 urlmon.idl
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\um\msxml.idl
 msxml.idl
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\um\oaidl.acf
 oaidl.acf
 Processing C:\Program Files (x86)\Windows Kits\8.1\Include\um\ocidl.acf
 ocidl.acf
ClCompile:
 C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _WINDOWS /D _USRDLL /D _VC80_UPGRADE=0x0600 /D _WINDLL /D _MBCS /D _AFXDLL /Gm /EHsc /RTC1 /MDd /GS /Gy- /Zc:wchar_t /Zc:forScope /Yc"stdafx.h" /Fp".\Debug\LFA.pch" /Fo".\Debug\\" /Fd".\Debug\vc120.pdb" /FR".\Debug\\" /Gd /TP /analyze- /errorReport:prompt LiveFluidAnalyserContainer.cpp LFA.cpp LFAInterface.cpp StdAfx.cpp
 StdAfx.cpp
1>c:\program files (x86)\microsoft visual studio 12.0\vc\atlmfc\include\afx.h(38): warning C4996: 'MBCS_Support_Deprecated_In_MFC': MBCS support in MFC is deprecated and may be removed in a future version of MFC.
     c:\program files (x86)\microsoft visual studio 12.0\vc\atlmfc\include\afx.h(33) : see declaration of 'MBCS_Support_Deprecated_In_MFC'
 LFAInterface.cpp
 LFA.cpp
 LiveFluidAnalyserContainer.cpp
ResourceCompile:
 C:\Program Files (x86)\Windows Kits\8.1\bin\x86\rc.exe /D _DEBUG /D _VC80_UPGRADE=0x0600 /D _AFXDLL /l"0x0409" /I.\Debug\ /nologo /fo".\Debug\LFA.res" LFA.rc
Link:
 C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:".\Debug\LFA.dll" /INCREMENTAL /NOLOGO /LIBPATH:\compiler\lib\ia32 mtx.lib delayimp.lib .\Debug\LFA_lib_.lib Delayimp.lib /DEF:".\LFA.def" /DELAYLOAD:mtxex.dll /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /manifestinput:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Include\Manifest\dpiaware.manifest" /DEBUG /PDB:".\Debug\LFA.pdb" /SUBSYSTEM:WINDOWS /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\Debug\LFA.lib" /MACHINE:X86 /SAFESEH /DLL .\Debug\LFA.res
 .\Debug\LiveFluidAnalyserContainer.obj
 .\Debug\LFA.obj
 .\Debug\LFAInterface.obj
 .\Debug\StdAfx.obj
1>LiveFluidAnalyserContainer.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
    Creating library .\Debug\LFA.lib and object .\Debug\LFA.exp
1>LINK : warning LNK4199: /DELAYLOAD:mtxex.dll ignored; no imports found from mtxex.dll
1>LFAInterface.obj : error LNK2019: unresolved external symbol _MMODELCURFIT@32 referenced in function "public: virtual long __stdcall CLFAInterface::DoLFA(int)" (?DoLFA@CLFAInterface@@UAGJH@Z)
1>.\Debug\LFA.dll : fatal error LNK1120: 1 unresolved externals
1>Done Building Project "D:\FLOWSERVE\Server\Components\LFA\LFA.vcxproj" (Rebuild target(s)) -- FAILED.

Build FAILED.

Time Elapsed 00:00:41.06
===========================================================================


 

Additional Information:
1. Added Libraries
Right Click -> VC++ Directories (LFA Properties Pages)
Library Directories : $(IFORT_COMPILER15)\compiler\lib\ia32;$(LibraryPath)

2. Since this is a C++ COM application the usage of pre-compiled header is used which will be used in downstream applications. However at the level the Pre-compiler header is Created.

3. The dependencies in C++ code for the fortran function is defined as
 

extern "C" short int _stdcall MMODELCURFIT (short int *nfit,short int *nrowa,short int *ncola,double *a,short int *nrowb,short int *ncolb,double *b,short int *excel);

4. The fortran code is defined as

      INTEGER*2 FUNCTION MMODELCURFIT(N_FIT,NROWA,NCOLA,A,NROWB,NCOLB,B,ROWWISE)
      IMPLICIT NONE
      !DEC$ATTRIBUTES DLLEXPORT, REFERENCE :: MMODELCURFIT
      ...........
      ...........
      ...........
      ...........
      ...........
      END FUNCTION

   There are several subroutines in the fortran files which will be referenced by the main program "MMODELCURFIT"

5. In the As-IS Visual Studio 6 the fortran file get compiled with the same source folder and the link utilises its object file (.obj) to Build and link. I Understand this procedure is not followed with the IVF.

 

Any inputs/approach/reference material to resolve this issue is very much appreciable.

Thanks

Asha

 


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>