如何找到包含必要方法实现的静态库?

时间:2014-06-05 05:40:15

标签: bash static-libraries

我正在尝试在iOS应用程序中使用静态库。似乎我已经完成了所有事情,但我得到了多个“未定义的架构i386符号”错误(SO question)。我决定检查实现必要方法的位置(包含方法代码的静态库):

#!/bin/bash
for filename in /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/lib*.a; do
    echo "  $filename:"
    nm "$filename" | grep getMemBufferCopy
done

在少数文件中找到了它:

MBA-Anton:StaticLibraryUsage2 asmirnov$ ./find_method 
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMAArch64AsmParser.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMAArch64AsmPrinter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMAArch64CodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMAArch64Desc.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMAArch64Disassembler.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMAArch64Info.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMAArch64Utils.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMARMAsmParser.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMARMAsmPrinter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMARMCodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMARMDesc.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMARMDisassembler.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMARMInfo.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMAnalysis.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMAsmParser.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMAsmPrinter.a:
         U __ZN4llvm12MemoryBuffer16getMemBufferCopyENS_9StringRefES1_
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMBitReader.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMBitWriter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMCodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMCore.a:
         U __ZN4llvm12MemoryBuffer16getMemBufferCopyENS_9StringRefES1_
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMCppBackendCodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMCppBackendInfo.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMDebugInfo.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMExecutionEngine.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMHexagonAsmPrinter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMHexagonCodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMHexagonDesc.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMHexagonInfo.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMIRReader.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMInstCombine.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMInstrumentation.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMInterpreter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMJIT.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMLTO.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMLinker.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMC.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMCDisassembler.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMCJIT.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMCParser.a:
         U __ZN4llvm12MemoryBuffer16getMemBufferCopyENS_9StringRefES1_
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMSP430AsmPrinter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMSP430CodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMSP430Desc.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMSP430Info.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMipsAsmParser.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMipsAsmPrinter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMipsCodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMipsDesc.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMipsDisassembler.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMMipsInfo.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMNVPTXAsmPrinter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMNVPTXCodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMNVPTXDesc.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMNVPTXInfo.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMObjCARCOpts.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMObject.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMOption.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMPowerPCAsmParser.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMPowerPCAsmPrinter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMPowerPCCodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMPowerPCDesc.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMPowerPCInfo.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMR600AsmPrinter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMR600CodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMR600Desc.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMR600Info.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMRuntimeDyld.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMScalarOpts.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMSelectionDAG.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMSparcCodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMSparcDesc.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMSparcInfo.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMSupport.a:
         U __ZN4llvm12MemoryBuffer16getMemBufferCopyENS_9StringRefES1_
000000b0 T __ZN4llvm12MemoryBuffer16getMemBufferCopyENS_9StringRefES1_
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMSystemZAsmParser.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMSystemZAsmPrinter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMSystemZCodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMSystemZDesc.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMSystemZDisassembler.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMSystemZInfo.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMTableGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMTarget.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMTransformUtils.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMVectorize.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMX86AsmParser.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMX86AsmPrinter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMX86CodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMX86Desc.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMX86Disassembler.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMX86Info.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMX86Utils.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMXCoreAsmPrinter.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMXCoreCodeGen.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMXCoreDesc.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMXCoreDisassembler.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMXCoreInfo.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMipa.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLLVMipo.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libLTO.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangARCMigrate.a:
         U __ZN4llvm12MemoryBuffer16getMemBufferCopyENS_9StringRefES1_
         U __ZN4llvm12MemoryBuffer16getMemBufferCopyENS_9StringRefES1_
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangAST.a:
         U __ZN4llvm12MemoryBuffer16getMemBufferCopyENS_9StringRefES1_
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangASTMatchers.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangAnalysis.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangBasic.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangCodeGen.a:
         U __ZN4llvm12MemoryBuffer16getMemBufferCopyENS_9StringRefES1_
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangDriver.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangDynamicASTMatchers.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangEdit.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangFormat.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangFrontend.a:
         U __ZN4llvm12MemoryBuffer16getMemBufferCopyENS_9StringRefES1_
         U __ZN4llvm12MemoryBuffer16getMemBufferCopyENS_9StringRefES1_
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangFrontendTool.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangIndex.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangLex.a:
         U __ZN4llvm12MemoryBuffer16getMemBufferCopyENS_9StringRefES1_
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangParse.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangRewriteCore.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangRewriteFrontend.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangSema.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangSerialization.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangStaticAnalyzerCheckers.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangStaticAnalyzerCore.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangStaticAnalyzerFrontend.a:
  /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_/lib/libclangTooling.a:

所以它似乎找到了用法而不是实现。我该怎么做才能正确(找到带有方法impl的.a文件)?

1 个答案:

答案 0 :(得分:0)

当我输入

nm --help

我明白了:

Usage: nm [option(s)] [file(s)]
 List symbols in [file(s)] (a.out by default).
 The options are:
  -a, --debug-syms       Display debugger-only symbols
  -A, --print-file-name  Print name of the input file before every symbol
  -B                     Same as --format=bsd
  -C, --demangle[=STYLE] Decode low-level symbol names into user-level names
                          The STYLE, if specified, can be `auto' (the default),
                          `gnu', `lucid', `arm', `hp', `edg', `gnu-v3', `java'
                          or `gnat'
      --no-demangle      Do not demangle low-level symbol names
  -D, --dynamic          Display dynamic symbols instead of normal symbols
      --defined-only     Display only defined symbols
  -e                     (ignored)
  -f, --format=FORMAT    Use the output format FORMAT.  FORMAT can be `bsd',
                           `sysv' or `posix'.  The default is `bsd'
  -g, --extern-only      Display only external symbols
  -l, --line-numbers     Use debugging information to find a filename and
                           line number for each symbol
  -n, --numeric-sort     Sort symbols numerically by address
  -o                     Same as -A
  -p, --no-sort          Do not sort the symbols
  -P, --portability      Same as --format=posix
  -r, --reverse-sort     Reverse the sense of the sort
      --plugin NAME      Load the specified plugin
  -S, --print-size       Print size of defined symbols
  -s, --print-armap      Include index for symbols from archive members
      --size-sort        Sort symbols by size
      --special-syms     Include special symbols in the output
      --synthetic        Display synthetic symbols as well
  -t, --radix=RADIX      Use RADIX for printing symbol values
      --target=BFDNAME   Specify the target object format as BFDNAME
  -u, --undefined-only   Display only undefined symbols
  -X 32_64               (ignored)
  @FILE                  Read options from FILE
  -h, --help             Display this information
  -V, --version          Display this program's version number

nm: supported targets: elf64-x86-64 elf32-i386 elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
Report bugs to .

这是在Linux台式机上。