Reputation: 907
I have added libxxx.a in /usr/lib but when I perform otool -L myproject.so, libxxx.a was not included in the list of libraries. I have also included libxxx.a in my build file so I was thinking that I have successfully added it.
How can I like .a file?
I didn't have a problem with .dylib files though.
Upvotes: 1
Views: 2485
Reputation: 122401
otool
won't show the static library as they are included within the executable binary (a .dylib
in this case). This is because static libraries are a collection of object (.o
) files and it's pretty much the same as adding file1.o ... fileN.o
to the linker command line and you can't see object files from otool
either.
One way to check that your static library is part of the executable (other than it successfully linking) is to use the nm
command which lists symbols. Providing the executable binary is not stripped, you would do something like:
$ nm /path/to/libLibrary.dylib | grep aClassOrFunctionInStaticLibrary
and the symbol being searched should have the letter t
next to it, to indicate that it's part of the executable text section.
Also as mentioned by @PaulR, /usr/lib
is part of the operating system and you should not add files there; use /usr/local/lib
instead as /usr/local
is designed for site-specific additions to the system and files there will survive an operating system update.
Upvotes: 1