ARM Technical Support Knowledge Articles

NOT FINDING SOME FUNCTIONS IN LIBRARIES

Applies to: BL51 Code-banking Linker/Locator

Answer


Information in this article applies to:


SYMPTOMS

The linker is not finding some functions in my libraries.

In main.c, I have a call to foo(). foo() calls bar().

foo() is in library foo.lib.

bar() is in library bar.lib.

I run the linker from the command line:

BL51 main.obj, bar.lib, foo.lib

I get these messages:

*** WARNING 1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  BAR
    MODULE:  FOO.LIB (FOO)

*** WARNING 2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  BAR
    MODULE:  FOO.LIB (FOO)
    ADDRESS: 0014H

CAUSE

The linker processes files in the order you specify them. From library files, it takes only those modules required to satisfy unresolved external references it has already encountered.

In this example, when the linker reads bar.lib there have been no references to bar(), so the linker does not link bar() into the program. When it reads foo.lib, it is able to resolve the reference to foo(). Since foo() calls bar(), this creates a reference to bar(). The linker does not backtrack to reprocess library files it has already read, so this reference to bar() is never resolved.

RESOLUTION

There are two ways to solve this problem:

  1. Present the dependent library (foo.lib) to the linker before the library upon which it depends (bar.lib). For example:
    BL51 main.obj, foo.lib, bar.lib
    
  2. Force the linker to include the necessary modules even though it has not yet seen any references to them. This is done by enclosing the name of the module in parentheses after the library name. For example:
    BL51 main.obj, bar.lib (bar), foo.lib
    

SEE ALSO

Article last edited on: 2005-07-09 11:22:57

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential