- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 ''
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 "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, thanks for your answers!
-Ralf

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page