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

unresolved external symbol

Ralf
Beginner
543 Views
Hi group,
this is probably a FAQ but a quick forum search did not answer my question:
the linker complained with:
error LNK2019: unresolved external symbol BLA referenced in function MAIN__
Question: is there an option to let me know on which line the error ocurred? I always look with {STRG}+{F} ...
Cheers
-Ralf
0 Kudos
3 Replies
mecej4
Honored Contributor III
543 Views
It should go without saying that if the objects being linked were not compiled with line number information embedded, you should not expect your wish to be fulfilled.

There are at least three reasons for a symbol being flagged as an unresolved external:

(a) the symbol is truly an unresolved external symbol

(b) a variable declared as an array was used with subscripts properly in an expression or Fortran statement, but the name was misspelled

(c) a variable was used with subscripts in an expression or an otherwise valid Fortran statement but was not declared as an array

With all three of these cases, within a single compilation unit there can be multiple occurrences of offending usage. Unless all subprograms are endowed with explicit interfaces, or interface checking across multiple source files is enabled, errors of type (a) can be detected only at link time.

If all errors in a compilation unit are of type (a), line-number information will not be of much use: you have to fix up the linker command to include external libraries that will provide the missing external, and you do not change any of the lines in the source code where the symbol is used. This remains true even if the unsatisfied external is used in more than one of the object files being linked.

If there are any errors of types (b) or (c), using IMPLICIT NONE (by explicitly including this statement in every subprogram, by using modules in which only correct declarations were used, or by using a compiler option) will enable the compiler to tell you the line number where the error occurs.

At the command line, you may use these commands to produce a selective listing with line numbers:

$ grep -in ''

and/or

C:\> find /I /N ""

0 Kudos
Steven_L_Intel1
Employee
543 Views
By the time the linker is involved, it has no idea which line number the reference came in. All it can tell you is the name of the procedure. If you enable listing files (in version 12/Composer XE 2011), you can look at the cross-reference table in the listing file to find the line number.
0 Kudos
Ralf
Beginner
543 Views
Ok, thanks for your answers!
-Ralf
0 Kudos
Reply