简体   繁体   中英

Object files do not contain symbols that should be there

This is the specific error I am getting:

libFoo.so: undefined reference to `IID_IFOOBAR'
collect2: ld returned 1 exit status
make: *** [/home/F.exe] Error 1

when I try to check the symbols in my object file Ao

nm A.obj | grep IID_

I get no symbols listed in my object file of the 'IID_IFOOBAR' that should be there since it is defined in a header file as:

extern const blahType IID_IFOOBAR

Am I missing something? Should IID_IFOOBAR be defined differently somewhere since it is an extern variable? If this question is too specific I will remove it. But perhaps someone's intuition will help me here.

[EDIT] Add the definition of the variable somewhere (without extern ). Extern identifiers without initializers are not definitions - the definition must be somewhere else.

To make an extern ly declared symbol appear in your symbol table as "undefined", you should actually use it from within a library.

If your object file neither contains a definition of symbol (as opposed to declaration) nor uses it somewhere inside its functions, then the symbol won't appear in the symbol table. Why should it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM