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

Can not build on MacOS m1 #1192

Closed alex-bender closed 1 year ago

alex-bender commented 1 year ago

After launching cmake .. i'm getting error:

Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)

despite all required libs are being installed

Is that expectable not to compile on m1?

JonathanSalwan commented 1 year ago

I do not have an M1, so I can not test but you can define python directories like this:

cmake -DPYTHON_LIBRARIES=/path/to/your/libpython.dylib -DPYTHON_INCLUDE_DIRS=/path/to/your/python/include ..

alex-bender commented 1 year ago

I will try build it with that and report back, thanks!

plague-lab commented 1 year ago

This worked for me on M1

cmake -DPYTHON_LIBRARIES=/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib  -DPYTHON_INCLUDE_DIRS=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Vers
ions/3.10/include/python3.10/ ..

To find what are the one for you

from sysconfig import get_paths
info = get_paths()
print(info)
# This will ouput the /include/

And for the .so

locate libpython 
alex-bender commented 1 year ago

@plague-lab thanks for help, that did help to build it @JonathanSalwan what do you think, would it be good to improve installation notes on that?

Unfortunately I've got following problem. Looks like lib is installed but still can not use it

-- Installing: /usr/local/lib/cmake/triton/tritonConfig.cmake
-- Installing: /usr/local/lib/cmake/triton/tritonConfigVersion.cmake
-- Installing: /usr/local/lib/python3.10/site-packages/triton.so
build ~ λ % python
Python 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from triton import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'triton'
alex-bender commented 1 year ago

ok, looks like wrong dirs it's looking into.

This snipped fixing this:

>>> import site
>>> site.addsitedir('/usr/local/lib/python3.10/site-packages')
JonathanSalwan commented 1 year ago

@alex-bender

@JonathanSalwan what do you think, would it be good to improve installation notes on that?

Yeah it's a good idea. Can I let you do the MR?

alex-bender commented 1 year ago

Yes, sure!

alex-bender commented 1 year ago

https://github.com/JonathanSalwan/Triton/pull/1194 Here is PR