Keil Logo

BL51: NOT FINDING SOME FUNCTIONS IN LIBRARIES


Information in this article applies to:

  • C51 Version 5.50
  • C51 Version 6.00 Beta
  • C51 Version 6.00

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

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Saturday, July 9, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.