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

error LNK2019: unresolved external symbol

Carlos_O_3
Beginner
2,168 Views

Hello,

  I am woking on a fortran code. The code makes a reference to a file named netcdf.inc, which contains the definitions of several variables to be used in the main program. This netcdf.inc file is part of the build Resource files, and yet when I try compiling I get the error "LNK2019: unresolved external symbol" for every single variable that is defined in netcdf.inc and is referenced in the main code. I am kind of new to this so I would appreciate any guidance on why this may be happening - I've tried including the various variables within the main code and forego the whole "include netcdf.inc" to see if that was the problem, but that didn't fix the bug. Within the 'netcdf.inc' file, the variables are defined like this:

   integer         nf_create
   external        nf_create

For each of them. Not sure if that helps. I'm attaching a screenshot of my workspace. Thank you!

Carlos Oropeza

0 Kudos
8 Replies
TimP
Honored Contributor III
2,168 Views

Netcdf typically requires that you first build and install the netcdf library, then set an environment variable which sets linker search path (or  take advantage of the linker dependencies VS project setup option).

There was a lengthy discussion at http://software.intel.com/en-us/forums/topic/281318 which is easlly found by normal search tactics.

0 Kudos
mecej4
Honored Contributor III
2,168 Views

Carlos,

Note that in Fortran "defined" has a definite meaning, which is not the same as "declared". The lines from the include file that you showed DO NOT define symbols/variables such as nf_create. They simply provide attributes (such as INTEGER and EXTERNAL) to the compiler so that it can emit correct code.

You are probably not including a NetCDF library at link time -- a library in which the actual executable code for the integer function nf_create is contained.

0 Kudos
Said_E_
Beginner
2,168 Views

Hi,

I have just started ivf 11.1.051. I have a problem in linking libraries. After collecting all libraries I know, I still have the error "libirc.lib(tbk_backtrack.obj): LNK 2019: Unresolved external symbol _imp_xxxxxxxxx referenced in function tbk_trace_stack". This message repeats for imp_SymInitialize, imp_StackWalk64, and imp_SymCleanup.

Best regards.

Prof. Dr, Said El Noshokaty 

0 Kudos
TimP
Honored Contributor III
2,168 Views

Such references from libirc.lib should be taken care of automatically in a normal installation of ifort, using ifort to complete the link step.  The compiler normally would choose libircmt.lib which should satisfy such references itself.  If I remember correctly, non-thread-safe linking was last supported with VS2005 (32-bit).

0 Kudos
Steven_L_Intel1
Employee
2,168 Views

Those symbols should be resolved by linking against dbghelp.lib. This is a Windows library that should be automatically pulled in. Perhaps you are doing your build in a way that prevents this.

I will also comment that 11.1.051 is four years old.

0 Kudos
Said_E_
Beginner
2,168 Views

Hi Tim,

Hi Steve,

Thank you for help. 

'libircmt.lib' is not selected by ifort. 'libcmt' is selected instead. Command-line ifort is installed with 'no vs shell' option. OS is Win 7 professional (64-bit), updated by Windows platform SDK.

Linking against dbghelp.lib results in same error.

Best regards.

Prof. Dr, Said El Noshokaty 

0 Kudos
Steven_L_Intel1
Employee
2,168 Views

Please set the project property Linker > General > Show Progress Messages to Show All Progress Messages. Do a rebuild of the project and then attach a ZIP of the buildlog.htm from the Debug or Release folder to a reply here. This may give us a clue.

0 Kudos
Said_E_
Beginner
2,168 Views

Hi Steve,

Linking against x64 version of ImageHlp.lib and Uuid.lib results in no errors. Thank you for your support.

Best regards.

Prof. Dr, Said El Noshokaty 

0 Kudos
Reply