I frequently have this problem when linking
<archive>(<file>):<mangled symbol> undefined reference to <unmangled symbol>
.
Finds which object references/defines a symbol given the symbol and list of
objects/directories.
Example linker error:
/home/nick/llvm/build/lib/libclangFrontend.a(TextDiagnosticBuffer.cpp.o):(.data.rel.ro._ZTVN5clang20TextDiagnosticBufferE[_ZTVN5clang20TextDiagnosticBufferE]+0x40): undefined reference to `clang::DiagnosticConsumer::IncludeInDiagnosticCounts() const'
Usage: ./find_symbol.py <symbol> [directories/files]
Takes the symbol you're searching for (unmangled), and a list of directories
or files to search (searching the current working directory if these aren't
specified). Prints the symbol type (from nm
) and path to object file.
Example:
$ ./find_symbol.py clang::DiagnosticConsumer::IncludeInDiagnosticCounts ~/llvm/build/lib
found clang::DiagnosticConsumer::IncludeInDiagnosticCounts in:
t /home/nick/llvm/build/lib/libclang.so.8svn
U /home/nick/llvm/build/lib/libclangFrontend.aT /home/nick/llvm/build/lib/libclangBasic.a
t /home/nick/llvm/build/lib/libclang.so.8
U /home/nick/llvm/build/lib/libclangTooling.a
U /home/nick/llvm/build/lib/libclangARCMigrate.at /home/nick/llvm/build/lib/libclang.so
$ cd ~/llvm/build/lib
$ ~/code/python/find_symbol/find_symbol.py clang::DiagnosticConsumer::IncludeInDiagnosticCounts
found clang::DiagnosticConsumer::IncludeInDiagnosticCounts in:
t /home/nick/llvm/build/lib/libclang.so.8svn
U /home/nick/llvm/build/lib/libclangFrontend.a
T /home/nick/llvm/build/lib/libclangBasic.a
t /home/nick/llvm/build/lib/libclang.so.8
U /home/nick/llvm/build/lib/libclangTooling.a
U /home/nick/llvm/build/lib/libclangARCMigrate.a
t /home/nick/llvm/build/lib/libclang.so
$ ~/code/python/find_symbol/find_symbol.py clang::DiagnosticConsumer::IncludeInDiagnosticCounts libclangBasic.a libclang.so
found clang::DiagnosticConsumer::IncludeInDiagnosticCounts in:
T libclangBasic.a
t libclang.so
See man 1 nm
, but T
is a global/external/public definition, t
is private
definition, and U
is undefined but referenced.
"THE BEER-WARE LICENSE" (Revision 42): [email protected] wrote this file. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Nick Desaulniers