Comments (12)
The last time I built it for Windows, I downloaded the source and all the dependencies (LLVM, Z3, Capstone...) then I opened the folder with cmake-gui. You have to manually enable features and enter the paths to your downloaded libraries. You should also enable PYTHON_BINDINGS_AUTOCOMPLETE. Click configure until there are no errors then click generate and make sure you only have warnings and no errors. Then you can open the solution in VS. Build python-triton and triton_autocomplete. Now you should have the .pyd and .pyi files that you can copy to your python site-packages directory. If you get any errors while building you probably didn't set up the dependecies correctly in CMAKE.
from triton.
Cher Andrix44!
Well, that sounds like a really good answer!
I shall definitely try it ASAP and then report back the results to the community!
Thanks a lot!
from triton.
Follow up for anyone as well, to build Release builds on Windows with pre-built LLVM support. Note: still running into issues when generating debug builds of my projects using Triton, but for Release builds it's fine.
option(ASAN "Enable the ASAN linking" OFF)
option(BITWUZLA_INTERFACE "Use Bitwuzla as SMT solver" OFF)
option(BUILD_SHARED_LIBS "Build a shared library" ON)
option(GCOV "Enable code coverage" OFF)
option(LLVM_INTERFACE "Use LLVM for lifting" ON)
option(MSVC_STATIC "Use statically-linked runtime library" OFF)
option(Z3_INTERFACE "Use Z3 as SMT solver" ON)
option(BOOST_INTERFACE "Use Boost as multiprecision library" OFF)
option(PYTHON_BINDINGS_AUTOCOMPLETE "Generate an autocomplete stub file" ON)
I'm using PowerShell to set the dependencies as such, but you can readily adjust this to your build environment.
$BuildDir = "C:\code\triton\build"
# ---------------------------------------------------------------------------------
# z3 pre-built dependencies
# > pre-build: https://github.com/Z3Prover/z3/releases/download/z3-4.8.9/z3-4.8.9-x64-win.zip
# ---------------------------------------------------------------------------------
$Z3_INCLUDE_DIRS = "$BuildDir\z3\include"
$Z3_LIBRARIES_DIR = "$BuildDir\z3\bin"
$Z3_LIBRARIES = "$Z3_LIBRARIES_DIR\libz3.lib"
# ---------------------------------------------------------------------------------
# capstone 4.0.2 pre-built dependencies
# > build first, straightforward
# ---------------------------------------------------------------------------------
$CAPSTONE_INCLUDE_DIRS = "$BuildDir\capstone-4.0.2\include"
$CAPSTONE_LIBRARIES = "$BuildDir\capstone-4.0.2\msvc\x64\Release\capstone.lib"
# ---------------------------------------------------------------------------------
# LLVM15 pre-installed
# > https://github.com/LLVMParty/REVIDE/releases/download/libraries/llvm-15.0.3-win64.7z
# ---------------------------------------------------------------------------------
$LLVM_PREFIX = "C:\code\llvm-15.0.3-win64"
$LLVM_DIR = "$LLVM_DIR\lib\cmake\llvm" # needs to find LLVMConfig.cmake
NOTE: for LLVM, he has a hardcoded path for diaguids.pdb
that could cause an issue when building. You can adjust to your build environment by modifying the LLVMExports.cmake
file or the .csprojx
file after running cmake
.
> llvm-15.0.3-win64
kd > rg "diaguids"
lib/cmake\llvm\LLVMExports.cmake
406: INTERFACE_LINK_LIBRARIES "c:/Program Files/Microsoft Visual Studio/2022/Community/DIA SDK/lib/amd64/diaguids.lib;LLVMBinaryFormat;LLVMObject;LLVMSupport;LLVMDebugInfoCodeView;LLVMDebugInfoMSF"
Then generate the build scripts as such (targeting Python11 here):
cmake -DLLVM_INTERFACE=ON -DCMAKE_PREFIX_PATH="$LLVM_PREFIX" -DLLVM_DIR="$LLVM_DIR" -DPYTHON_VERSION="3.11" -DCAPSTONE_INCLUDE_DIRS="$CAPSTONE_INCLUDE_DIRS" -DCAPSTONE_LIBRARIES="$CAPSTONE_LIBRARIES" -DZ3_INCLUDE_DIRS="$Z3_INCLUDE_DIRS" -DZ3_LIBRARIES_DIR="$Z3_LIBRARIES_DIR".. -A x64
msbuild C:\code\triton\build\triton.sln /property:Configuration=Release /property:Platform=x64 /t:triton /t:python-triton /m:3
For both builds, the native and Python, make sure libz3.dll
is always accessible, since it's a direct dependency.
from triton.
Also check that all deps like z3 are into the same folder than triton.pyd
from triton.
I copied and pasted this set of files in a few places....
the capstone DLL
the lib Z3 dll
the triton DLL
i also duplicated all of them, and changed the extension to pyd
I get this error when trying to import triton from the vcpkg:
Python.Runtime.PythonException: 'ImportError : dynamic module does not define module export function (PyInit_triton)'
using the artifacts for x64 from the build (from https://ci.appveyor.com/project/JonathanSalwan/triton/history) results in this error:
Python.Runtime.PythonException: 'ModuleNotFoundError : No module named 'triton.language'; 'triton' is not a package'
any ideas?
from triton.
PyInit_triton
makes me think about an issue around Python version (compile vs runtime). Is the Python version used during the compile is the same than the one used at runtime?
from triton.
Hello, dear friends!
Pretty much the same situation installing triton and referencing it from python script.
Could somebody in the name of charity and goodwill explain how to handle this problem? Detailed instruction would be very much appreciated since i am out of options after trying all recommended steps...
Thanks in advance!
from triton.
Sorry guys, I can't help you on that side as i do not have a Windows on hand.
from triton.
Awesome, thanks a lot for this feedback!
from triton.
Follow up for anyone as well, to build Release builds on Windows with pre-built LLVM support. Note: still running into issues when generating debug builds of my projects using Triton, but for Release builds it's fine.
option(ASAN "Enable the ASAN linking" OFF) option(BITWUZLA_INTERFACE "Use Bitwuzla as SMT solver" OFF) option(BUILD_SHARED_LIBS "Build a shared library" ON) option(GCOV "Enable code coverage" OFF) option(LLVM_INTERFACE "Use LLVM for lifting" ON) option(MSVC_STATIC "Use statically-linked runtime library" OFF) option(Z3_INTERFACE "Use Z3 as SMT solver" ON) option(BOOST_INTERFACE "Use Boost as multiprecision library" OFF) option(PYTHON_BINDINGS_AUTOCOMPLETE "Generate an autocomplete stub file" ON)
I'm using PowerShell to set the dependencies as such, but you can readily adjust this to your build environment.
$BuildDir = "C:\code\triton\build" # --------------------------------------------------------------------------------- # z3 pre-built dependencies # > pre-build: https://github.com/Z3Prover/z3/releases/download/z3-4.8.9/z3-4.8.9-x64-win.zip # --------------------------------------------------------------------------------- $Z3_INCLUDE_DIRS = "$BuildDir\z3\include" $Z3_LIBRARIES_DIR = "$BuildDir\z3\bin" $Z3_LIBRARIES = "$Z3_LIBRARIES_DIR\libz3.lib" # --------------------------------------------------------------------------------- # capstone 4.0.2 pre-built dependencies # > build first, straightforward # --------------------------------------------------------------------------------- $CAPSTONE_INCLUDE_DIRS = "$BuildDir\capstone-4.0.2\include" $CAPSTONE_LIBRARIES = "$BuildDir\capstone-4.0.2\msvc\x64\Release\capstone.lib" # --------------------------------------------------------------------------------- # LLVM15 pre-installed # > https://github.com/LLVMParty/REVIDE/releases/download/libraries/llvm-15.0.3-win64.7z # --------------------------------------------------------------------------------- $LLVM_PREFIX = "C:\code\llvm-15.0.3-win64" $LLVM_DIR = "$LLVM_DIR\lib\cmake\llvm" # needs to find LLVMConfig.cmake
NOTE: for LLVM, he has a hardcoded path for
diaguids.pdb
that could cause an issue when building. You can adjust to your build environment by modifying theLLVMExports.cmake
file or the.csprojx
file after runningcmake
.> llvm-15.0.3-win64 kd > rg "diaguids" lib/cmake\llvm\LLVMExports.cmake 406: INTERFACE_LINK_LIBRARIES "c:/Program Files/Microsoft Visual Studio/2022/Community/DIA SDK/lib/amd64/diaguids.lib;LLVMBinaryFormat;LLVMObject;LLVMSupport;LLVMDebugInfoCodeView;LLVMDebugInfoMSF"
Then generate the build scripts as such (targeting Python11 here):
cmake -DLLVM_INTERFACE=ON -DCMAKE_PREFIX_PATH="$LLVM_PREFIX" -DLLVM_DIR="$LLVM_DIR" -DPYTHON_VERSION="3.11" -DCAPSTONE_INCLUDE_DIRS="$CAPSTONE_INCLUDE_DIRS" -DCAPSTONE_LIBRARIES="$CAPSTONE_LIBRARIES" -DZ3_INCLUDE_DIRS="$Z3_INCLUDE_DIRS" -DZ3_LIBRARIES_DIR="$Z3_LIBRARIES_DIR".. -A x64
msbuild C:\code\triton\build\triton.sln /property:Configuration=Release /property:Platform=x64 /t:triton /t:python-triton /m:3
For both builds, the native and Python, make sure
libz3.dll
is always accessible, since it's a direct dependency.
How do you compile the latest llvm,The official installer does not have a complete list of cmake files
from triton.
How do you compile the latest llvm,The official installer does not have a complete list of cmake files
Hello! I asked a very similar question here:
Their response was priceless!
from triton.
How do you compile the latest llvm,The official installer does not have a complete list of cmake files
Hello! I asked a very similar question here: Their response was priceless! Check it out!
After searching through the files you mentioned, I guess you can compile using lazel.
from triton.
Related Issues (20)
- assembly question HOT 1
- update the latest version of capstone HOT 5
- Consider switching to using `Py_LIMITED_API`
- Linux Kernel dynamic taint analysis HOT 1
- Support for ARM32 ldm<amode> HOT 5
- No "rflags" register in x86_64 architecture HOT 2
- bitwuzla error: no matching function HOT 11
- python setup.py install bug HOT 9
- Old cmake in dockerfile (release build 0.9) HOT 2
- alternative pintools HOT 10
- Missing header files in releases? HOT 1
- Call to getStackPointer in release build of triton.dll fails when main program is in debug mode HOT 1
- Taint resulting from a dereference HOT 2
- Taint propagation on conditional jumps HOT 1
- Once contain “inc edi” or “dec edi”,TritonContext.disassembly(block, start) generate TypeError: x8664Cpu::disassembly(): Failed to disassemble the given code. HOT 3
- Will a new official version be released soon? HOT 3
- Problem with getWrittenRegisters() in aarch64
- ARM32 - `ADR` Instruction incorrect behaviour HOT 3
- Why is this POC yielding these results? HOT 2
- Failed to build with the library HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from triton.