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

"unresolved external symbol" issue when building NetCDF with Intel Foxtran OneAPI

MichaelCao
Beginner
1,089 Views

Hi all,

In the past, we can integrate Netcdf with Intel Parallel Studio in our foxtran project successfully. I have been trying to integrate NetCDF with the latest OneAPI using Visual Studio 2019. I set the "additional including directories" in the Foxtran section to the folder "NetCDFLib\x64\include" and set the "Additional library Directory" to the folder NetCDFLib\x64\lib properly (Please see the attached files for more details).

I see the following errors after building the project

------ Build started: Project: EFDCPlus_MPI_10.3.0, Configuration: 64SP_D_MPI x64 ------
Linking...
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_DEF_VAR_MANYDIMS referenced in function MOD_NETCDF_mp_NC_DEFINE_VARS
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_DEF_VAR_DEFLATE referenced in function MOD_NETCDF_mp_NC_DEFINE_VARS
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_PUT_ATT_TEXT referenced in function MOD_NETCDF_mp_NC_DEFINE_VARS
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_PUT_ATT_ONE_FOURBYTEREAL referenced in function MOD_NETCDF_mp_NC_DEFINE_VARS
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_CREATE referenced in function MOD_NETCDF_mp_NC_CREATE_FILE
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_DEF_DIM referenced in function MOD_NETCDF_mp_NC_CREATE_FILE
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_DEF_VAR_SCALAR referenced in function MOD_NETCDF_mp_NC_CREATE_FILE
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_PUT_ATT_ONE_EIGHTBYTEREAL referenced in function MOD_NETCDF_mp_NC_CREATE_FILE
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_ENDDEF referenced in function MOD_NETCDF_mp_NC_CREATE_FILE
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_CLOSE referenced in function MOD_NETCDF_mp_NC_CLOSE_FILE
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_STRERROR referenced in function MOD_NETCDF_mp_CHECK_ERR
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_PUT_VAR_1D_FOURBYTEREAL referenced in function MOD_NETCDF_mp_NC_WRITE_SCALAR1D
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_PUT_VAR_2D_FOURBYTEREAL referenced in function MOD_NETCDF_mp_NC_WRITE_SCALAR2D
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_PUT_VAR_3D_FOURBYTEREAL referenced in function MOD_NETCDF_mp_NC_WRITE_SCALAR3D
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_PUT_VAR_4D_FOURBYTEREAL referenced in function MOD_NETCDF_mp_NC_WRITE_CLASS3D
od_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_PUT_VAR_2D_ONEBYTEINT referenced in function MOD_NETCDF_mp_NC_WRITE_ZBOT
mod_netcdf.obj : error LNK2019: unresolved external symbol NETCDF_mp_NF90_PUT_VAR_1D_EIGHTBYTEREAL referenced in function MOD_NETCDF_mp_NC_WRITE_SNAPSHOT
SP_D_MPI\EFDCPlus_MPI_10.3.0.exe : fatal error LNK1120: 17 unresolved externals

Do I need to rebuild Netcdf dll and lib using OneAPI C++ compiler? Please help me to resolve this issue as soon as possible. Thanks  in advance.

 

0 Kudos
5 Replies
Steve_Lionel
Honored Contributor III
1,031 Views

It's not helpful to show a screenshot of a property window where the contents are truncated.

The missing references are to the object file created when Fortran module NETCDF was compiled. I can't tell from your attachments exactly how you should go about fixing that.

0 Kudos
MichaelCao
Beginner
995 Views

I just attached full screenshots of property windows.  Please give me an idea how to fix this issue. It works well when I used the intel parallel studio in the past. Thanks.

0 Kudos
Steve_Lionel
Honored Contributor III
971 Views

You didn't show the linker property page. If you could attach a zip of the .vfproj file that might help. As I wrote earlier, the unresolved references are to the .obj created when Fortran module NETCDF was compiled.

I did see you have set the calling convention to "C, REFERENCE".  This is a bad idea, though isn't the cause of this particular issue as far as I can tell. 

0 Kudos
MichaelCao
Beginner
958 Views

I just attached the linker property page.   I tried all options of calling convention ("C, REFERENCE", "STDCALL REFERENCE", "STDCALL", "CVF") and nothing works. You can see the vfproj file as belows:

<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioProject ProjectCreator="Intel Fortran" Keyword="Console Application" Version="11.0" ProjectIdGuid="{8F3F0269-93FE-4360-B2AD-B35BE7DA4202}">
<Platforms>
<Platform Name="Win32"/>
<Platform Name="x64"/></Platforms>
<Configurations>
<Configuration Name="64SP_R_MPI|Win32">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true"/>
<Tool Name="VFLinkerTool" SuppressStartupBanner="true"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
<Configuration Name="64SP_R_MPI|x64" OutputDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" TargetName="$(ProjectName)_201118">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" MultiProcessorCompilation="true" Optimization="optimizeFull" Preprocess="preprocessYes" AdditionalIncludeDirectories="$(I_MPI_ROOT)\intel64\include;..\NetCDFLib\x64\include" PreprocessorDefinitions="_WIN64;_WIN;_MPI;NCOUT;TRIAL" UndefinePreprocessorDefinitions="_WIN32" OpenMP="OpenMPParallelCode" FloatingPointExceptionHandling="fpe0" FloatingPointModel="source" FloatingPointSpeculation="fpSpeculationSafe" CallingConvention="callConventionCRef" Traceback="true" RuntimeChecks="rtChecksNone" RuntimeLibrary="rtMultiThreadedDLL"/>
<Tool Name="VFLinkerTool" OutputFile="$(OutDir)\$(TargetName).exe" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" AdditionalLibraryDirectories="$(I_MPI_ROOT)\intel64\lib\release;..\NetCDFLib\x64\lib" IgnoreDefaultLibraryNames="libcmt.lib;mscvrt.lib;libifcoremt.lib" GenerateManifest="false" SubSystem="subSystemConsole" StackReserveSize="10000000" InterproceduralOptimizations="false" AdditionalDependencies="impi.lib netcdf4.lib netcdf_f.lib netcdf.lib"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
<Configuration Name="64SP_D_MPI|Win32">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" LocalSavedScalarsZero="true" InitArrays="true"/>
<Tool Name="VFLinkerTool" SuppressStartupBanner="true"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
<Configuration Name="64SP_D_MPI|x64" OutputDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" MultiProcessorCompilation="true" Optimization="optimizeDisabled" Preprocess="preprocessYes" AdditionalIncludeDirectories="C:\Program Files (x86)\Intel\oneAPI\mpi\2021.1.1\include;..\NetCDFLib\x64\include" PreprocessorDefinitions="_WIN64;_WIN;_MPI;NCOUT;TRIAL;DEBUGGING" UndefinePreprocessorDefinitions="_WIN32" OpenMP="OpenMPParallelCode" FloatingPointExceptionHandling="fpe0" FloatingPointModel="source" FloatingPointStackCheck="true" CallingConvention="callConventionCRef" Traceback="true" RuntimeChecks="rtChecksAll" NullPointerCheck="true" BoundsCheck="true" ArrayShapeCheck="true" UninitializedVariablesCheck="true" DescriptorDataTypeCheck="true" DescriptorDataSizeCheck="true" StackFrameCheck="true" RuntimeLibrary="rtMultiThreadedDebugDLL"/>
<Tool Name="VFLinkerTool" OutputFile="$(OutDir)\$(TargetName).exe" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" AdditionalLibraryDirectories="C:\Program Files (x86)\Intel\oneAPI\mpi\2021.1.1\lib\debug;..\NetCDFLib\x64\lib" IgnoreDefaultLibraryNames="libcmtd.lib;mscvrtd.lib;libifcoremt.lib" GenerateDebugInformation="true" GenerateMapFile="true" SubSystem="subSystemConsole" StackReserveSize="10000000" InterproceduralOptimizations="false" AdditionalDependencies="impi.lib netcdf4.lib netcdf_f.lib netcdf.lib"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true" TargetEnvironment="midlTargetAMD64"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
<Configuration Name="64DP_D_MPI|x64">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" MultiProcessorCompilation="true" Optimization="optimizeDisabled" Preprocess="preprocessYes" AdditionalIncludeDirectories="$(I_MPI_ROOT)\intel64\include;..\NetCDFLib\x64\include" PreprocessorDefinitions="_WIN64;_WIN;_MPI;NCOUT;TRIAL;DEBUGGING" UndefinePreprocessorDefinitions="_WIN32" RealKIND="realKIND8" LocalSavedScalarsZero="true" FloatingPointExceptionHandling="fpe0" FloatingPointModel="source" FloatingPointStackCheck="true" CallingConvention="callConventionCRef" Traceback="true" RuntimeChecks="rtChecksAll" NullPointerCheck="true" BoundsCheck="true" ArrayShapeCheck="true" StackFrameCheck="true" RuntimeLibrary="rtMultiThreadedDLL"/>
<Tool Name="VFLinkerTool" OutputFile="$(OutDir)\$(TargetName).exe" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" AdditionalLibraryDirectories="$(I_MPI_ROOT)\intel64\lib\release" IgnoreDefaultLibraryNames="libcmtd.lib;mscvrtd.lib;libifcoremt.lib" GenerateDebugInformation="true" SubSystem="subSystemConsole" StackReserveSize="10000000" InterproceduralOptimizations="false" AdditionalDependencies="impi.lib netcdf4.lib netcdf_f.lib netcdf.lib"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true" TargetEnvironment="midlTargetAMD64"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
<Configuration Name="64DP_D_MPI|Win32">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" LocalSavedScalarsZero="true" InitArrays="true"/>
<Tool Name="VFLinkerTool" SuppressStartupBanner="true"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
<Configuration Name="64DP_R_MPI|x64">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" MultiProcessorCompilation="true" Optimization="optimizeFull" Preprocess="preprocessYes" AdditionalIncludeDirectories="$(I_MPI_ROOT)\intel64\include;..\NetCDFLib\x64\include" PreprocessorDefinitions="_WIN64;_WIN;_MPI;NCOUT;TRIAL;DEBUGGING" UndefinePreprocessorDefinitions="_WIN32" RealKIND="realKIND8" LocalSavedScalarsZero="true" FloatingPointExceptionHandling="fpe0" FloatingPointModel="source" FloatingPointStackCheck="true" FloatingPointSpeculation="fpSpeculationSafe" CallingConvention="callConventionCRef" Traceback="true" RuntimeChecks="rtChecksNone" BoundsCheck="true" ArrayShapeCheck="true" StackFrameCheck="true" RuntimeLibrary="rtMultiThreadedDLL"/>
<Tool Name="VFLinkerTool" OutputFile="$(OutDir)\$(TargetName).exe" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" AdditionalLibraryDirectories="$(I_MPI_ROOT)\intel64\lib\release" IgnoreDefaultLibraryNames="libcmtd.lib;mscvrtd.lib;libifcoremt.lib" SubSystem="subSystemConsole" StackReserveSize="10000000" InterproceduralOptimizations="false" AdditionalDependencies="impi.lib netcdf4.lib netcdf_f.lib netcdf.lib"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true" TargetEnvironment="midlTargetAMD64"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
<Configuration Name="64DP_R_MPI|Win32">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" LocalSavedScalarsZero="true" InitArrays="true"/>
<Tool Name="VFLinkerTool" SuppressStartupBanner="true"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration></Configurations>
<Files>
<Filter Name="Header Files" Filter="fi;fd"/>
<Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"/>
<Filter Name="Source Files" Filter="f90;for;f;fpp;ftn;def;odl;idl">
<Filter Name="Drifter">
<File RelativePath=".\Drifter\mod_drifter.f90"/>
<File RelativePath=".\Drifter\Variables_MPI_Drifter.f90"/></Filter>
<Filter Name="Eutrophication">
<File RelativePath=".\Eutrophication\mod_diagen.f90"/>
<Filter Name="JSON_Reader">
<File RelativePath=".\JSON_Reader\fson.f90">
<FileConfiguration Name="64SP_D_MPI|x64">
<Tool Name="VFFortranCompilerTool" RuntimeChecks="rtChecksCustom" NullPointerCheck="false"/></FileConfiguration></File>
<File RelativePath=".\JSON_Reader\fson_path_m.f90"/>
<File RelativePath=".\JSON_Reader\fson_string_m.f90"/>
<File RelativePath=".\JSON_Reader\fson_value_m.f90"/></Filter>
<Filter Name="MPI_Communication">
<FileConfiguration Name="64SP_R_MPI|x64">
<Tool Name="VFFortranCompilerTool" Optimization="optimizeDisabled"/></FileConfiguration></File>
<File RelativePath=".\varalloc.f90">
<FileConfiguration Name="64SP_R_MPI|x64">
<Tool Name="VFFortranCompilerTool" Optimization="optimizeDisabled"/></FileConfiguration></File>
<File RelativePath=".\varinit.f90">
<FileConfiguration Name="64SP_R_MPI|x64">
<Tool Name="VFFortranCompilerTool" Optimization="optimizeDisabled"/></FileConfiguration></File>
<File RelativePath=".\varzeroint.f90">
<FileConfiguration Name="64SP_R_MPI|x64">
<Tool Name="VFFortranCompilerTool" Optimization="optimizeDisabled"/></FileConfiguration></File>
<File RelativePath=".\varzeroreal.f90">
<FileConfiguration Name="64SP_R_MPI|x64">
<Tool Name="VFFortranCompilerTool" Optimization="optimizeDisabled"/></FileConfiguration></File>
<File RelativePath=".\varzerosnl.f90">
<FileConfiguration Name="64SP_R_MPI|x64">
<Tool Name="VFFortranCompilerTool" Optimization="optimizeDisabled"/></FileConfiguration></File>
<File RelativePath=".\wasp4.f90"/>
<File RelativePath=".\xyijconv.f90"/></Filter></Files>
<Globals/></VisualStudioProject>

Please let me know if you need any additional information. Thanks.

0 Kudos
Steve_Lionel
Honored Contributor III
937 Views

I did say that the calling convention property was not relevant - it was simply something I thought you should not use.

Another option you should not use is "Ignore default libraries". 

As I have written more than once, the unresolved references would be supplied in the object file from a Fortran module called NETCDF. Your task is to find out where that is supposed to be supplied from. At this point you're just throwing things against the wall.  I assume that somewhere in your program is a "USE NETCDF". This will look for a netcdf.mod file, probably in some Include folder such as \NetCDFLib\x64\include . The question I can't answer for you is - where is the .obj file that goes with netcdf.mod? It apparently is not inserted into any of the libraries you link against. If you find it, add it to the "source files" for the project.

0 Kudos
Reply