Shuzheng
Shuzheng

Reputation: 13840

Where do I see what parts of LLVM a library contain?

I know how to see which libraries a certain component correponds to with the command:

llvm-config --libs core

Now, suppose I get a linker error and wants to include another library to resolve it.

Say, the linker can't resolve some symbol A. Then how do I:

1) Find the library that contains the specific symbol, like e.g. LLVMCore.lib.

2) Look up contents of libraries to see what symbols it defines?

I don't understand how to do this reading the documentation.

Upvotes: 2

Views: 288

Answers (2)

Marco A.
Marco A.

Reputation: 43662

As you have already discovered a proper LLVM-way to do this would be using llvm-config by indicating the components you intend to link against or use, e.g.

llvm-config --cxxflags --ldflags --system-libs --libs core

Other common non-llvm specific methods that you can use to find a symbol: on a Win platform (use VS native tools cmd or equivalent environment-set one):

for %f in (*.lib) do (dumpbin.exe /symbols %f | findstr /C:"your_symbol") 

if you can't deal with findstr's limitations GNU grep might be a better choice. If you have unix tools installed and in your PATH you can also use

for %f in (*.lib) do (nm -gC %f | findstr /C:"your_symbol")

as baddger964 suggests.

On a unix system:

for lib in $(find . -name \*.so) ; do nm -gC $lib | grep my_symbol | grep -v " U " ; done

(search *.so libraries in this directory for my_symbol; extern-only, demangle and exclude undefined symbols)

Given the above question 2 is trivial.

Upvotes: 2

baddger964
baddger964

Reputation: 1227

One way to see symbols of your lib is to use the nm command :

nm -gC mylib.so

Upvotes: 1

Related Questions