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.39k stars 524 forks source link

Failed to build with the library #1302

Closed oureveryday closed 6 months ago

oureveryday commented 6 months ago

Seems like it can't get work with Titan. It's very strange that other exports works, only this one triton::ast::LLVMToTriton::LLVMToTriton(class triton::Context &) gets error.

Don't know what's wrong. Do I need to use gcc/mingw instead of visual studio to build?

solver.obj : error LNK2019: unresolved external symbol "public: __cdecl triton::ast::LLVMToTriton::LLVMToTriton(class triton::Context &)" (??0LLVMToTriton@ast@triton@@QEAA@AEAVContext@2@@Z),function "class std::vector<unsigned __int64,class std::allocator<unsigned __int64> > __cdecl il::get_possible_targets(class llvm::Value *)" (?get_possible_targets@il@@YA?AV?$vector@_KV?$allocator@_K@std@@@std@@PEAVValue@llvm@@@Z) [D:\1\1\titan\build\titan.vcxproj]

JonathanSalwan commented 6 months ago

Looks like a setup issue when compiling with LLVM. Maybe double check how you compiled Triton with your LLVM framework?

oureveryday commented 6 months ago

Using Visual Studio 2022 compliter + cmake tools in vscode, it occurred many problems that I have to manually add .lib files into the visual studio project linker settings (I know it's an incorrect way, but I can't find other way to fix that, already added the lib folder using link_directories("D:/1/1/llvm/llvm/build/Release/lib")) Also this LLVM class also not work class llvm::Value *

oureveryday commented 6 months ago

Oh I think i should enable this option -DLLVM_INTERFACE=ON. Thanks!

--Edit--

Tested and worked! Thanks again! Also the best way to build it is using Cmake Install. (Install the library to anywhere and choose the folder with xxx-config.cmake)

JonathanSalwan commented 6 months ago

Yeah, sorry I should mention it. As LLVM is a strong dependency, we don't compile it by default. Just to give more insights for others people that could read this thread. Here is how I compile Triton on my setup:

cmake -DCAPSTONE_INCLUDE_DIRS=/Users/jonathan/Works/Tools/capstone-5.0.1/include/ \
      -DCAPSTONE_LIBRARIES=/Users/jonathan/Works/Tools/capstone-5.0.1/libcapstone.a \
      -DCAPSTONE_VERSION_HEADER=/Users/jonathan/Works/Tools/capstone-5.0.1/include/capstone/capstone.h \
      -DCMAKE_INSTALL_PREFIX=/opt/homebrew/ \
      -DPYTHON_EXECUTABLE=/opt/homebrew/bin/python3 \
      -DPYTHON_LIBRARIES=/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib \
      -DPYTHON_INCLUDE_DIRS=/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11/ \
      -DLLVM_INTERFACE=ON \
      -DCMAKE_PREFIX_PATH=/Users/jonathan/Works/Tools/llvm-project-14.0.0/build \
      -DBITWUZLA_INTERFACE=ON \
      -DBITWUZLA_INCLUDE_DIRS=/usr/local/include/ \
      -DBITWUZLA_LIBRARIES="/usr/local/lib/libbitwuzla.dylib" \
      -DBOOST_INTERFACE=OFF \
      ..

Cheers,

ConnorBP commented 4 months ago

I'm getting this error with the vcpkg install. The manual cmake method has been failing to make a valid visual studio project for me all day. Is there any way to add this -DLLVM_INTERFACE=ON flag on the vcpkg build? I have all but given up on a manual install. The build instructions simply ain't working out for me due to some unknown reason