JonathanSalwan / Triton

Triton is a dynamic binary analysis library. Build your own program analysis tools, automate your reverse engineering, perform software verification or just emulate code.
https://triton-library.github.io
Apache License 2.0
3.4k stars 524 forks source link

mac m1 build error #1245

Closed badguy123 closed 1 year ago

badguy123 commented 1 year ago

Hi, i want build this library, but have some error. i use mac book pro m1, os: 12.6 When i type make -j3 it failed with Linking CXX shared library libtriton.dylib, too many Undefined symbols

cmake -DPYTHON_EXECUTABLE=/opt/homebrew/bin/python3 \
-DPYTHON_LIBRARIES=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/lib \
-DPYTHON_INCLUDE_DIRS=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 \
..
make -j3
...
[ 87%] Linking CXX shared library libtriton.dylib
Undefined symbols for architecture arm64:
  "_PyArg_ParseTuple", referenced from:
      triton::bindings::python::triton_BasicBlock(_object*, _object*) in tritonCallbacks.cpp.o
      triton::bindings::python::triton_Immediate(_object*, _object*) in tritonCallbacks.cpp.o
      triton::bindings::python::triton_Instruction(_object*, _object*) in tritonCallbacks.cpp.o
      triton::bindings::python::triton_MemoryAccess(_object*, _object*) in tritonCallbacks.cpp.o
      triton::bindings::python::triton_TritonContext(_object*, _object*) in tritonCallbacks.cpp.o
      triton::bindings::python::AstContext_bv(_object*, _object*) in pyAstContext.cpp.o
      triton::bindings::python::AstContext_bvadd(_object*, _object*) in pyAstContext.cpp.o
      ...
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/libtriton/CMakeFiles/triton.dir/build.make:1509: src/libtriton/libtriton.dylib] Error 1
make[1]: *** [CMakeFiles/Makefile2:1016: src/libtriton/CMakeFiles/triton.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
JonathanSalwan commented 1 year ago

Probably an issue with your PYTHON_LIBRARIES. Below how I compile Triton on my M1.

cmake -DCAPSTONE_INCLUDE_DIRS=/Users/jonathan/Works/Tools/capstone-5.0-rc2/include/ \
      -DCAPSTONE_LIBRARIES=/Users/jonathan/Works/Tools/capstone-5.0-rc2/libcapstone.5.dylib \
      -DCAPSTONE_VERSION_HEADER=/Users/jonathan/Works/Tools/capstone-5.0-rc2/include/capstone/capstone.h \
      -DCMAKE_INSTALL_PREFIX=/opt/homebrew/ \
      -DPYTHON_EXECUTABLE=/opt/homebrew/bin/python3 \
      -DPYTHON_LIBRARIES=/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib \
      -DPYTHON_INCLUDE_DIRS=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10/ \
      -DLLVM_INTERFACE=ON \
      -DCMAKE_PREFIX_PATH=/Users/jonathan/Works/Tools/llvm-project-14.0.0/build \
      -DBOOST_INTERFACE=OFF \
      -DBITWUZLA_INTERFACE=ON \
      ..
badguy123 commented 1 year ago

My -DPYTHON_LIBRARIES path not add libpython3.10.dylib, its my mistake :)