Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nm: "U" The symbol is undefined

When I nm on one of my libs:

nm libmylib.so

I get a line like this

             U _ZNSs4_Rep20_S_empty_rep_storageE@@GLIBCXX_3.4 

I checked the man page for nm and I got "U" The symbol is undefined. What does an undefined symbol really mean?

If it is really undefined, then why does nm report it at all?

like image 281
bbazso Avatar asked Feb 24 '10 21:02

bbazso


People also ask

What is an undefined symbol?

A symbol remains undefined when a symbol reference in a relocatable object is never matched to a symbol definition. Similarly, if a shared object is used to create a dynamic executable and leaves an unresolved symbol definition, an undefined symbol error results.

What does U mean in NM?

NMU is an acronym used to mean Not much, you. It's used in reply to the question, “What's up?” or “What are you doing?,” often expressed as WYD (what you doing).

How do you use nm command?

The nm command displays information about symbols in the specified File, which can be an object file, an executable file, or an object-file library. If the file contains no symbol information, the nm command reports the fact, but does not interpret it as an error condition.


1 Answers

An undefined symbol is a symbol that the library uses but was not defined in any of the object files that went into creating the library.

Usually the symbol is defined in another library which also needs to be linked in to your application. Alternatively the symbol is undefined because you've forgotten to build the code that defines the symbol or you've forgotten to include the object file with that symbol into your library.

In your case it looks like a symbol from your implementation's C library so you would expect that to be undefined in your own library. It will be defined in your libc.so wherever that is, possibly /usr/lib.

like image 89
Troubadour Avatar answered Oct 06 '22 17:10

Troubadour