capstone-engine / capstone

Capstone disassembly/disassembler framework for ARM, ARM64 (ARMv8), Alpha, BPF, Ethereum VM, HPPA, LoongArch, M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), SH, Sparc, SystemZ, TMS320C64X, TriCore, Webassembly, XCore and X86.
http://www.capstone-engine.org
7.57k stars 1.55k forks source link

pip install --user capstone is not working at OSX Mojave (14.14 Beta (18A353D)) #1235

Closed cokia closed 6 years ago

cokia commented 6 years ago

pip install --user capstone is not working at OSX Mojave (14.14 Beta (18A353D))

 ~  pip install --user capstone   
Collecting capstone
  Using cached https://files.pythonhosted.org/packages/5d/87/5f70f3f28e65aeb86f57d3c887fb7f47ba9ce56afb359bec581671db15fc/capstone-3.0.5.tar.gz
Installing collected packages: capstone
  Running setup.py install for capstone ... error
    Complete output from command /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/fc/8zhjnwgx1j96dfrg0_yvw2w80000gn/T/pip-install-vl858gja/capstone/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/fc/8zhjnwgx1j96dfrg0_yvw2w80000gn/T/pip-record-vw5zeimm/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    running install
    running build
    Building C extensions
      CC      cs.o
      CC      utils.o
      CC      SStream.o
      CC      MCInstrDesc.o
      CC      MCRegisterInfo.o
      CC      arch/ARM/ARMDisassembler.o
      CC      arch/ARM/ARMInstPrinter.o
      CC      arch/ARM/ARMMapping.o
      CC      arch/ARM/ARMModule.o
      CC      arch/AArch64/AArch64BaseInfo.o
      CC      arch/AArch64/AArch64Disassembler.o
      CC      arch/AArch64/AArch64InstPrinter.o
      CC      arch/AArch64/AArch64Mapping.o
      CC      arch/AArch64/AArch64Module.o
      CC      arch/Mips/MipsDisassembler.o
      CC      arch/Mips/MipsInstPrinter.o
      CC      arch/Mips/MipsMapping.o
      CC      arch/Mips/MipsModule.o
      CC      arch/PowerPC/PPCDisassembler.o
      CC      arch/PowerPC/PPCInstPrinter.o
      CC      arch/PowerPC/PPCMapping.o
      CC      arch/PowerPC/PPCModule.o
      CC      arch/Sparc/SparcDisassembler.o
      CC      arch/Sparc/SparcInstPrinter.o
      CC      arch/Sparc/SparcMapping.o
      CC      arch/Sparc/SparcModule.o
      CC      arch/SystemZ/SystemZDisassembler.o
      CC      arch/SystemZ/SystemZInstPrinter.o
      CC      arch/SystemZ/SystemZMapping.o
      CC      arch/SystemZ/SystemZModule.o
      CC      arch/SystemZ/SystemZMCTargetDesc.o
      CC      arch/X86/X86DisassemblerDecoder.o
      CC      arch/X86/X86Disassembler.o
      CC      arch/X86/X86IntelInstPrinter.o
      CC      arch/X86/X86ATTInstPrinter.o
      CC      arch/X86/X86Mapping.o
      CC      arch/X86/X86Module.o
      CC      arch/XCore/XCoreDisassembler.o
      CC      arch/XCore/XCoreInstPrinter.o
      CC      arch/XCore/XCoreMapping.o
      CC      arch/XCore/XCoreModule.o
      CC      MCInst.o
      LINK    libcapstone.dylib
    ld: warning: The i386 architecture is deprecated for macOS (remove from Xcode build setting: ARCHS)
    ld: warning: ignoring file /Applications/xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Applications/xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd
    Undefined symbols for architecture i386:
      "___bzero", referenced from:
          _Thumb_getInstruction in ARMDisassembler.o
          _ARM_getInstruction in ARMDisassembler.o
          _AArch64_getInstruction in AArch64Disassembler.o
          _Mips_getInstruction in MipsDisassembler.o
          _Mips64_getInstruction in MipsDisassembler.o
          _PPC_getInstruction in PPCDisassembler.o
          _Sparc_getInstruction in SparcDisassembler.o
          ...
      "___memcpy_chk", referenced from:
          _SystemZ_getInstruction in SystemZDisassembler.o
      "___stack_chk_fail", referenced from:
          _cs_disasm in cs.o
          _cs_disasm_iter in cs.o
          _ARM_get_insn_id in ARMMapping.o
          _A64SysRegMapper_toString in AArch64BaseInfo.o
          _decodeToMCInst in AArch64Disassembler.o
          _printInstruction in AArch64InstPrinter.o
          _printTypedVectorList in AArch64InstPrinter.o
          ...
      "___stack_chk_guard", referenced from:
          _cs_disasm in cs.o
          _cs_disasm_iter in cs.o
          _ARM_get_insn_id in ARMMapping.o
          _A64SysRegMapper_toString in AArch64BaseInfo.o
          _decodeToMCInst in AArch64Disassembler.o
          _printInstruction in AArch64InstPrinter.o
          _printTypedVectorList in AArch64InstPrinter.o
          ...
          _cs_disasm in cs.o
          _cs_disasm_iter in cs.o
          _ARM_get_insn_id in ARMMapping.o
          _A64SysRegMapper_toString in AArch64BaseInfo.o
          _decodeToMCInst in AArch64Disassembler.o
          _printInstruction in AArch64InstPrinter.o
          _printTypedVectorList in AArch64InstPrinter.o
          ...
          _cs_disasm in cs.o
          _cs_disasm_iter in cs.o
          _ARM_get_insn_id in ARMMapping.o
          _A64SysRegMapper_toString in AArch64BaseInfo.o
          _decodeToMCInst in AArch64Disassembler.o
          _printInstruction in AArch64InstPrinter.o
          _printTypedVectorList in AArch64InstPrinter.o
          ...
          _cs_disasm in cs.o
          _cs_disasm_iter in cs.o
          _ARM_get_insn_id in ARMMapping.o
          _A64SysRegMapper_toString in AArch64BaseInfo.o
          _decodeToMCInst in AArch64Disassembler.o
          _printInstruction in AArch64InstPrinter.o
          _printTypedVectorList in AArch64InstPrinter.o
          ...
          _cs_disasm in cs.o
          _cs_disasm_iter in cs.o
          _ARM_get_insn_id in ARMMapping.o
          _A64SysRegMapper_toString in AArch64BaseInfo.o
          _decodeToMCInst in AArch64Disassembler.o
          _printInstruction in AArch64InstPrinter.o
          _printTypedVectorList in AArch64InstPrinter.o
          ...
          _cs_disasm in cs.o
          _cs_disasm_iter in cs.o
          _ARM_get_insn_id in ARMMapping.o
          _A64SysRegMapper_toString in AArch64BaseInfo.o
          _decodeToMCInst in AArch64Disassembler.o
          _printInstruction in AArch64InstPrinter.o
          _printTypedVectorList in AArch64InstPrinter.o
          ...
          _cs_disasm in cs.o
          _cs_disasm_iter in cs.o
          _ARM_get_insn_id in ARMMapping.o
          _A64SysRegMapper_toString in AArch64BaseInfo.o
          _decodeToMCInst in AArch64Disassembler.o
          _printInstruction in AArch64InstPrinter.o
          _printTypedVectorList in AArch64InstPrinter.o
          ...
          ...
      "___strcpy_chk", referenced from:
          _XCore_insn_extract in XCoreInstPrinter.o
      "___strncpy_chk", referenced from:
          _Sparc_printInst in SparcInstPrinter.o
      "___tolower", referenced from:
          _A64NamedImmMapper_fromString in AArch64BaseInfo.o
      "___udivdi3", referenced from:
          _A64SysRegMapper_toString in AArch64BaseInfo.o
      "_atoi", referenced from:
          _XCore_insn_extract in XCoreInstPrinter.o
      "_calloc", referenced from:
          _cs_mem_calloc in cs.o
         (maybe you meant: _cs_mem_calloc)
      "_free", referenced from:
          _cs_mem_free in cs.o
         (maybe you meant: _cs_free, _cs_mem_free )
      "_malloc", referenced from:
          _cs_mem_malloc in cs.o
         (maybe you meant: _cs_malloc, _cs_mem_malloc )
      "_memcpy", referenced from:
          _cs_disasm in cs.o
          _fill_insn in cs.o
          _cs_disasm_iter in cs.o
          _SStream_concat0 in SStream.o
      "_memmove", referenced from:
          _cs_strdup in utils.o
          _X86_Intel_printInst in X86IntelInstPrinter.o
          _X86_ATT_printInst in X86ATTInstPrinter.o
      "_realloc", referenced from:
          _cs_mem_realloc in cs.o
         (maybe you meant: _cs_mem_realloc)
      "_strchr", referenced from:
          _Sparc_printInst in SparcInstPrinter.o
          _XCore_insn_extract in XCoreInstPrinter.o
          _XCore_printInst in XCoreInstPrinter.o
      "_strcmp", referenced from:
          _name2id in utils.o
          _A64NamedImmMapper_fromString in AArch64BaseInfo.o
          _printPredicateOperand in PPCInstPrinter.o
          _PPC_alias_insn in PPCMapping.o
          _printMemOperand in SparcInstPrinter.o
          _Sparc_map_hint in SparcMapping.o
          _XCore_reg_id in XCoreMapping.o
          ...
      "_strcpy", referenced from:
          _A64SysRegMapper_toString in AArch64BaseInfo.o
      "_strlen", referenced from:
          _cs_strdup in utils.o
          _SStream_concat0 in SStream.o
          _ARM_post_printer in ARMInstPrinter.o
          _PPC_printInst in PPCInstPrinter.o
          _Sparc_printInst in SparcInstPrinter.o
          _Sparc_map_hint in SparcMapping.o
      "_strncmp", referenced from:
          _ARM_post_printer in ARMInstPrinter.o
      "_strncpy", referenced from:
          _cs_disasm in cs.o
          _fill_insn in cs.o
          _cs_disasm_iter in cs.o
      "_strrchr", referenced from:
          _ARM_post_printer in ARMInstPrinter.o
          _AArch64_post_printer in AArch64InstPrinter.o
          _PPC_post_printer in PPCInstPrinter.o
      "_strstr", referenced from:
          _AArch64_printInst in AArch64InstPrinter.o
          _PPC_post_printer in PPCInstPrinter.o
          _printAliasInstr in SparcInstPrinter.o
      "_vsnprintf", referenced from:
          _cs_vsnprintf in cs.o
         (maybe you meant: _cs_vsnprintf)
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [libcapstone.dylib] Error 1
    error: [Errno 2] No such file or directory: 'libcapstone.dylib'

    ----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/fc/8zhjnwgx1j96dfrg0_yvw2w80000gn/T/pip-install-vl858gja/capstone/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/fc/8zhjnwgx1j96dfrg0_yvw2w80000gn/T/pip-record-vw5zeimm/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /private/var/folders/fc/8zhjnwgx1j96dfrg0_yvw2w80000gn/T/pip-install-vl858gja/capstone/
david9991 commented 6 years ago

Same issue.

blacktop commented 6 years ago

@aquynh macOS 10.14 (Mojave) deprecated support for i386 so removing it from https://github.com/aquynh/capstone/blob/master/Makefile#L13 would fix this.

t3hp0rP commented 6 years ago
  1. Download source package in https://pypi.org/project/capstone/#files
  2. Delete the i386 LIBARCHS in Your_PACKAGE PATH/src/MakeFile just like @blacktop said.
  3. Then run pip install Your_PACKAGE_PATH will work perfectly.
  4. Problem solved. Thanks to @blacktop
t3hp0rP commented 6 years ago

And same solution for unicorn in Mojave. Pwntools installed 😄

aquynh commented 6 years ago

Please send a pull req to remove i386, i will merge it, thanks.

cokia commented 6 years ago

I think this issue should close.. thanks for Contribution of all..!

Inndy commented 6 years ago

Try this as a temporary solution: https://gist.github.com/Inndy/cc9f725c22f23fe87182fd895e7e7ff3

MichaelBoublil commented 5 years ago

@Pr0phet Hi, I tried the same solution for unicorn but sadly it does not work for me. Could you please give me more details about what you removed from unicorn files ? Thank you !

disconnect3d commented 5 years ago

@MichaelHalfon See this for unicorn: https://github.com/unicorn-engine/unicorn/issues/206

For me, this worked on Mojave:

brew install unicorn && UNICORN_QEMU_FLAGS="--python=`whereis python`" pip install unicorn`
aquynh commented 5 years ago

We just released Capstone 4.0, which works for Mojave now. You can upgrade from older version with:

$ sudo pip install capstone --upgrade
ameisehaufen commented 5 years ago

I'm trying to use capstone==3.0.5rc2, but there is no LIBARCHS in the Makefile or in any file. Doesn't work either with changing MACOS_UNIVERSAL=no. Anyone had the same problem with this specific version? (I can't upgrade because I'm using roach 0.1.2 that needs capstone3.0.5rc2 only.)

I'm receiving the following error message:

LINK    libcapstone.dylib
  ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
  ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd
  Undefined symbols for architecture i386:
    "___bzero", referenced from:
        _Thumb_getInstruction in ARMDisassembler.o
        _ARM_getInstruction in ARMDisassembler.o
        _AArch64_getInstruction in AArch64Disassembler.o
        _Mips_getInstruction in MipsDisassembler.o
        _Mips64_getInstruction in MipsDisassembler.o
        _PPC_getInstruction in PPCDisassembler.o
        _Sparc_getInstruction in SparcDisassembler.o
        ...
"_vsnprintf", referenced from:
        _cs_vsnprintf in cs.o
       (maybe you meant: _cs_vsnprintf)
  ld: symbol(s) not found for architecture i386
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [libcapstone.dylib] Error 1
  error: [Errno 2] No such file or directory: 'libcapstone.dylib'
  ----------------------------------------
  Failed building wheel for capstone
  Running setup.py clean for capstone
Failed to build capstone
aquynh commented 5 years ago

we still keep the branch https://github.com/aquynh/capstone/tree/v3 for v3.

i can fix this Mojave issue in this branch if you want.

ameisehaufen commented 5 years ago

we still keep the branch https://github.com/aquynh/capstone/tree/v3 for v3. i can fix this Mojave issue in this branch if you want.

Thank you, I think it will be important for those who uses packages with depends on this specific version (I think there are a lot in this situation).

But, as a good workaround (It took me half of a day to realize that) is just to change the compiler from Xcode to gcc.

env CC=/usr/local/bin/gcc-8 pip install capstone-3.0.5rc2.tgz

I had some problems with libjpeg too. When I tryed to: cmake -DCAPSTONE_X86_SUPPORT=0 to remove x86 build (but didn't work anyway, even with corret libraries, it still try to build to x86)

 dyld: Symbol not found: __cg_jpeg_resync_to_restart
  Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
  Expected in: /usr/local/lib/libJPEG.dylib
 in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Abort trap: 6

It was using the home brew libraries. I had to do: export DYLD_LIBRARY_PATH=/usr/lib/:ADDITION_LIBRARY_PATH_LOCATION to avoid that.

I hope it help you to track bugs.